Skip to main content

python library for the zigate gateway (zigbee) http://zigate.fr

Project description

python library for zigate http://zigate.fr/ This library manage communication between python and zigate key, both USB and WiFi key are supported (wifi is almost untested) ZiGate is an universal gateway compatible with a lot of ZigBee device (like Xiaomi, Philipps Hue, Ikea, etc)

Getting Started

Installation

To install simply do:

pip3 install zigate

Usage

# if you want logging
import logging
logging.basicConfig()
logging.root.setLevel(logging.DEBUG)

import zigate
z = zigate.ZiGate(port=None) # Leave None to auto-discover the port

print(z.get_version())
OrderedDict([('major', 1), ('installer', '30c'), ('rssi', 0), ('version', '3.0c')])

print(z.get_version_text())
3.0c

# refresh devices list
z.get_devices_list()

# start inclusion mode
>>> z.permit_join()
>>> z.is_permitting_join()
True

# list devices
>>> z.devices
[Device 677c , Device b8ce , Device 92a7 , Device 59ef ]
>>> z.devices[0].addr
'677c'

# get all discovered endpoints
>>> z.devices[0].endpoints
{1: {
  'clusters': {0: Cluster 0 General: Basic,
   1026: Cluster 1026 Measurement: Temperature,
   1027: Cluster 1027 Measurement: Atmospheric Pressure,
   1029: Cluster 1029 Measurement: Humidity},
  }}


# get well known attributes
>>> for attribute in z.devices[0].properties:
     print(attribute)
{'data': 'lumi.weather', 'name': 'type', 'attribute': 5, 'value': 'lumi.weather'}
{'data': '0121c70b0421a8010521090006240100000000642932096521851c662bd87c01000a210000', 'name': 'battery', 'value': 3.015, 'unit': 'V', 'attribute': 65281}
{'data': -1983, 'name': 'temperature', 'value': -19.83, 'unit': '°C', 'attribute': 0}
{'data': 9779, 'name': 'pressure2', 'value': 977.9, 'unit': 'mb', 'attribute': 16}
{'data': 977, 'name': 'pressure', 'value': 977, 'unit': 'mb', 'attribute': 0}
{'data': 4484, 'name': 'humidity', 'value': 44.84, 'unit': '%', 'attribute': 0}

# get specific property
>>> z.devices[0].get_property('temperature')
{'data': -1983,
 'name': 'temperature',
 'value': -19.83,
 'unit': '°C',
 'attribute': 0}

Callback

We use pydispatcher for callback

from pydispatch import dispatcher

def my_callback(sender, signal, **kwargs):
   print(sender)  # zigate instance
   print(signal)  # one of EVENT
        print(kwargs)  # contains device and/or attribute changes, etc

dispatcher.connect(my_callback, zigate.ZIGATE_ATTRIBUTE_UPDATED)

z = zigate.ZiGate()

# to catch any events
dispatcher.connect(my_callback, dispatcher.Any)

event can be :

zigate.ZIGATE_DEVICE_ADDED
zigate.ZIGATE_DEVICE_UPDATED
zigate.ZIGATE_DEVICE_REMOVED
zigate.ZIGATE_ATTRIBUTE_ADDED
zigate.ZIGATE_ATTRIBUTE_UPDATED

kwargs depends of the event type for zigate.ZIGATE_DEVICE_ADDED: kwargs contains device

for zigate.ZIGATE_DEVICE_UPDATED kwargs contains device

for zigate.ZIGATE_DEVICE_REMOVED kwargs contains addr (the device short address)

for zigate.ZIGATE_ATTRIBUTE_ADDED: kwargs contains device and discovered attribute

for zigate.ZIGATE_ATTRIBUTE_UPDATED kwargs contains device and updated attribute

Wifi ZiGate

WiFi ZiGate is also supported :

import zigate
z = zigate.ZiGateWiFi(host='192.168.0.10', port=9999)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zigate-0.8.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

zigate-0.8.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file zigate-0.8.0.tar.gz.

File metadata

  • Download URL: zigate-0.8.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zigate-0.8.0.tar.gz
Algorithm Hash digest
SHA256 1935ef39749944ea8ef4ac2ab3b5706c19fd9ddf54492b842fbf3b08e623a5d1
MD5 9e35732daa8da477e0f9a171495748b1
BLAKE2b-256 8dfd1c331cd7fde9353a326f57f5ea3744e56f2b8ae350e353a02dd1d0cf060f

See more details on using hashes here.

Provenance

File details

Details for the file zigate-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for zigate-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95324a4bee36a2c6d61ef268b488b8dc12579edb7ad1453e4596ff55b0d95917
MD5 aa0663271bb4b0505933ad69469181fd
BLAKE2b-256 27b198d13acd9844be169ab9758ad8c692d2cc405f784b1c4b460f79968e2bdc

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page