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', '30b'), ('rssi', 0), ('version', '3.0b')])

print(z.get_version_text())
3.0b

# 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: {'0405_0000': {'endpoint': 1,
   'data': 3997,
   'cluster': 1029,
   'attribute': 0,
   'status': 0,
   'friendly_name': 'humidity',
   'value': 39.97,
   'unit': '%'},
  '0000_0005': {'endpoint': 1,
   'data': '6c756d692e77656174686572',
   'cluster': 0,
   'attribute': 5,
   'status': 0,
   'friendly_name': 'type',
   'value': 'lumi.weather',
   'unit': ''},
  '0000_0001': {'cluster': 0,
   'endpoint': 1,
   'status': 0,
   'attribute': 1,
   'data': 3},
  '0403_0000': {'endpoint': 1,
   'data': 976,
   'cluster': 1027,
   'attribute': 0,
   'status': 0,
   'friendly_name': 'pressure',
   'value': 976,
   'unit': 'mb'},
  '0000_ff01': {'cluster': 0,
   'endpoint': 1,
   'status': 0,
   'attribute': 65281,
   'data': '0121ef0b0421a81305210800062401000000006429a6096521a30f662b737d01000a210000'},
  '0403_0010': {'endpoint': 1,
   'data': 9762,
   'cluster': 1027,
   'attribute': 16,
   'status': 0,
   'friendly_name': 'detailled pressure',
   'value': 976.2,
   'unit': 'mb'},
  '0403_0014': {'cluster': 1027,
   'endpoint': 1,
   'status': 0,
   'attribute': 20,
   'data': -1},
  '0402_0000': {'endpoint': 1,
   'data': 2447,
   'cluster': 1026,
   'attribute': 0,
   'status': 0,
   'friendly_name': 'temperature',
   'value': 24.47,
   'unit': '°C'}}}


# get well known attributes
>>> for attribute in z.devices[0].properties:
     print(attribute)
{'endpoint': 1, 'data': 3997, 'cluster': 1029, 'attribute': 0, 'status': 0, 'friendly_name': 'humidity', 'value': 39.97, 'unit': '%'}
{'endpoint': 1, 'data': '6c756d692e77656174686572', 'cluster': 0, 'attribute': 5, 'status': 0, 'friendly_name': 'type', 'value': 'lumi.weather', 'unit': ''}
{'endpoint': 1, 'data': 976, 'cluster': 1027, 'attribute': 0, 'status': 0, 'friendly_name': 'pressure', 'value': 976, 'unit': 'mb'}
{'endpoint': 1, 'data': 9762, 'cluster': 1027, 'attribute': 16, 'status': 0, 'friendly_name': 'detailled pressure', 'value': 976.2, 'unit': 'mb'}
{'endpoint': 1, 'data': 2447, 'cluster': 1026, 'attribute': 0, 'status': 0, 'friendly_name': 'temperature', 'value': 24.47, 'unit': '°C'}

# get specific property
>>> z.devices[0].get_property('temperature')
{'endpoint': 1,
 'data': 2447,
 'cluster': 1026,
 'attribute': 0,
 'status': 0,
 'friendly_name': 'temperature',
 'value': 24.47,
 'unit': '°C'}

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

This version

0.7.3

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.7.3.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

zigate-0.7.3-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for zigate-0.7.3.tar.gz
Algorithm Hash digest
SHA256 0a6397097bef989717f0f0de04a1cf47fcbbd959034f09ecb9b4fbc92b1b8bf3
MD5 ea3f52b14065ecf1963f4e8c3c97385f
BLAKE2b-256 1cdf86a3e593c842a0d9a20f94087cdfe2915aa5db20809055b89d93c15d1d57

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for zigate-0.7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0db787fb50ca79e11c30a6ccaa57ccb0862b4dd5b6f366eb3d277b30d16072b2
MD5 c7957133b06839376bee689af48044d0
BLAKE2b-256 3710846b74208264a60260ded300af9445d1546b02882f5c8c367b96d2943841

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