elric91 / zigate Goto Github PK
View Code? Open in Web Editor NEWPython library for ZiGate
License: MIT License
Python library for ZiGate
License: MIT License
Please consider writing a ZiGate radio library that works with the zigpy library for Home Assistant:
https://github.com/zigpy/zigpy
zigpy is a is Zigbee protocol stack integration project that is designed to work with separate radio libraries which can each interface with multiple USB and GPIO radio adapters/modules over different native serial protocols.
This zigpy library is implemented as a native Zigbee Home Automation Hub (ZHA) component for Home Assistant.
https://www.home-assistant.io/components/zha/
The main benefit with the modular design of zigpy is that software like Home Assistant only need to support this one solution as zigpy then abstracts support for multiple radios serial protocols via radio module libraries:
https://github.com/zigpy/zigpy-xbee
https://github.com/zigpy/zigpy-deconz
https://github.com/zigpy/bellows
I followed your description and I was able to put the ZiGate into join mode but there is no debug output (as shown in your Session Example).
from threaded_serial import *
from pyzigate.interface import *
z = ZiGate()
conn = ThreadedConnection(z)
z.send_data('0049', 'FFFCFE00')
Do I have to enable the output somewhere?
I found out how to get some debug data:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('pyzigate')
Ref to elric91/homeassistant_zigate#4 (reference)
which must be corrected in the lib itself
Possible correction to test
In attributes_helpers.py :
temperature = int(hexlify(attribute_data), 16) / 100
Should be replaced with :
temperature = int.from_bytes(attribute_data, 'big', signed=True) / 100
It seems that it is only compatible with python 3.
I made a change that seems to make it working with python 2.7 but I'm not 100% sure of my modification as I'm not an exert and didn't test it in python 3.0
import six
def zigate_decode(data):
encoded = False
decoded_data = bytearray(b'')
for x in six.iterbytes(data):
if x == 0x02:
encoded = True
elif encoded is True:
encoded = False
decoded_data.append( x ^ 0x10 )
else:
decoded_data.append(x)
return decoded_data
I'm now able to read my sensor value . Thanks for your job !
clusters 000c & 0012 miss their set_device_property functions to be able to export info outside lib
Hi
I found zigate update attributes value only when aqare gadgets report attribute value.
Can zigate read the attributes value directly?
Hi,
I just try you zigate library but don't manage to get it work.
Here is the error :
In [1]: from interface import *
In [2]: z = ZiGate()
In [3]: conn = Threaded_connection(z)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-1f8fb7961259> in <module>()
----> 1 conn = Threaded_connection(z)
/opt/zigate/interface.py in __init__(self, device, port)
591
592 def __init__(self, device, port='/dev/ttyUSB0'):
--> 593 import serial
594 import threading
595
ImportError: No module named 'serial'
The zigate is correctly connected to my server :
user@srv:/opt/zigate$ lsusb | grep PL2303
Bus 001 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
I have installed pyserial too:
user@srv:/opt/zigate$ pip list | grep serial
pyserial (3.4)
serial (0.0.27)
Is there any else to do to get it work ?
Thanks in advance.
This is just note. This is not an issue.
Command: 0092
Message: '02' + short_address + '0101' + state
Parameters:
device short address
00
01
02
Command: 0081
Message: '02' + short_address + '0101' + onoff + level + time
Parameters:
target device short address
01
(Turns bulb on if its off)00
- FF
/ 0 - 25600
turns bulb Off0000
- FFFF
/ 0 - 65535Command: 00C0
Message: '02' + short_address + '0101' + temperature + time
Parameters:
target device short address
0100
- 0200
/ 256 - 512 = 2560000
- FFFF
/ 0 - 65535short_address = 6E8E
OFF: zigate.send_data('0092', '026E8E010100')
ON: zigate.send_data('0092', '026E8E010101')
Toggle: zigate.send_data('0092', '026E8E010102')
Brightness to min instant: zigate.send_data('0081', '026E8E010101010000')
Brightness to min fade: zigate.send_data('0081', '026E8E010101010010')
Brightness to max instant: zigate.send_data('0081', '026E8E010101FF0000')
Brightness to max fade: zigate.send_data('0081', '026E8E010101FF0010')
Brightness to 50% instant: zigate.send_data('0081', '026E8E010101800000')
Brightness to 50% fade: zigate.send_data('0081', '026E8E010101800010')
Color to cold white: zigate.send_data('00C0', '026E8E010101000000')
Color to warm white: zigate.send_data('00C0', '026E8E010102000000')
Color to middle: zigate.send_data('00C0', '026E8E010101800000')
I've got the following log on my ZiGate component:
[zigate] - Source EndPoint : b'01'
[zigate] - Cluster ID : b'0006'
[zigate] - Attribute ID : b'0000'
[zigate] - Attribute type : b'10'
[zigate] - Attribute size : 1
[zigate] - Attribute data : b'00'
[zigate] # encoded : b'018102120210021eefb52c82021102100216021002100210100210021102106f03'
[zigate] # decoded : 0181 02 00 0E EF B5 2C 82 01 00 06 00 00 00 10 00 01 00 6F03
[zigate] (@timestamp : 22:15:57)
[zigate] BAD LENGTH 33026 != 16
[zigate] # encoded : b'01e0018102120210021eefb82c82021102100216021002100210100210021102116303'
[zigate] # decoded : 01E0 01 81 02 00 0E EF B8 2C 82 01 00 06 00 00 00 10 00 01 01 6303
[zigate] (@timestamp : 22:16:02)
[zigate] --------------------------------------
[zigate] RESPONSE 8102 : Attribute Report / Response
[custom_components.zigate.zigate2hass] ZIGATE SIGNAL :
[custom_components.zigate.zigate2hass] - Signal : zgt_signal_update_2c8201
[custom_components.zigate.zigate2hass] - Property : last seen
[custom_components.zigate.zigate2hass] - Data : 2018-03-16 22:16:04
Is the bad length error always due to communication transmission issues?
For xiaomi sensor, it seems that the battery level is stored in FF01 attribute of cluster 0000
[2018-01-17 07:36:28][DEBUG] : RESPONSE 8102 : Attribute Report / Response
[2018-01-17 07:36:28][INFO] : FROM ADDRESS : 703e
[2018-01-17 07:36:28][DEBUG] : - Source EndPoint : 01
[2018-01-17 07:36:28][DEBUG] : - Cluster ID : 0000
[2018-01-17 07:36:28][DEBUG] : - Attribute ID : ff01
[2018-01-17 07:36:28][DEBUG] : - Attribute type : 42
[2018-01-17 07:36:28][DEBUG] : - Attribute size : 37
[2018-01-17 07:36:28][DEBUG] : - Attribute data : 0121bd0b0421a81305210600062401000000006429d00765219112662b3c8601000a210000
[2018-01-17 07:36:28][DEBUG] : # encoded : 01810212021032742b703e021102100210ff0211021042021025021121bd021b021421a81302152102160210021624021102100210021002106429d0021765219112662b3c8602110210021a2102100210b103
[2018-01-17 07:36:28][DEBUG] : # decoded : 0181 02 00 32 74 2B 70 3E 01 00 00 FF 01 00 42 00 25 01 21 BD 0B 04 21 A8 13 05 21 06 00 06 24 01 00 00 00 00 64 29 D0 07 65 21 91 12 66 2B 3C 86 01 00 0A 21 00 00 B103
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.