Giter VIP home page Giter VIP logo

zigate's People

Contributors

elric91 avatar ioull avatar iso-b avatar schumyhaojl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zigate's Issues

[REQUEST] ZiGate radio library to support for the zigpy library used by ZHA component in Home Assistant

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

Debug output not available

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')

Python 2.7 compatibility

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 !

Error : No module named 'serial'

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.

Ikea Trådfri commands

This is just note. This is not an issue.

Change bulb state:

Command: 0092
Message: '02' + short_address + '0101' + state
Parameters:

  • short_address device short address
  • state:
    • Off: 00
    • On: 01
    • Toggle: 02

Change brightness:

Command: 0081
Message: '02' + short_address + '0101' + onoff + level + time
Parameters:

  • short_address target device short address
  • onoff:
    • On: 01 (Turns bulb on if its off)
    • Might be possible to change brightness while bulb is off
  • level:
    • Brightness level between 00 - FF / 0 - 256
    • Level 00 turns bulb Off
  • time:
    • How long transition takes. 0000 - FFFF / 0 - 65535

Change color temperature:

Command: 00C0
Message: '02' + short_address + '0101' + temperature + time
Parameters:

  • short_address target device short address
  • temperature:
    • This is real color temperature. Lamp has 256 different steps.
    • Temperature between 0100 - 0200 / 256 - 512 = 256
  • time:
    • How long transition takes. 0000 - FFFF / 0 - 65535

Examples:

short_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')

Understanding BAD_LENGTH errors

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?

Add Battery Level decodage

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.