Another component for ZiGate


#102

Oh S**it,

So sorry to hear that mate.
You did a very great job (you make my zigate works again) ^^

Hope nothing bad happens.


#103

I’ve already follow to code made by @doudz. I will continue it on my side but I will directly create as HA integration and not a custom components.

Future evolution, if I had time, will be probably available in HA directly.


#104

thank you for all the fish!


#105

I’m sorry to hear that but thank you for the actual working component.
Does that mean that you will not work on the lib anymore?


#106

I’ll still use the lib for my own usage, so I will probably work on it some day but right now I need to focus on other real life stuff.
But if someone makes some PR, I’ll probably merge it.
it’s a goodbye, but I’ll be back :wink:


#107

Hi, thank you for this custom component.
I successfully connect my zigate to the component but don’t manage to get it work properly.

Here is the booting log

2018-08-22 22:18:24 DEBUG (Thread-2) [zigate] Try loading persistent file
2018-08-22 22:18:24 DEBUG (Thread-2) [zigate] Load success
2018-08-22 22:18:24 DEBUG (Thread-2) [zigate] REQUEST : 0x0010
2018-08-22 22:18:24 DEBUG (Thread-2) [zigate] Msg to send b'0010000010'
2018-08-22 22:18:24 DEBUG (Thread-2) [zigate] Encoded Msg to send b'\x01\x02\x10\x10\x02\x10\x02\x10\x10\x03'
2018-08-22 22:18:24 DEBUG (Thread-2) [zigate] Waiting for status message for command 0x0010
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] RESPONSE 0x8000 - Status response : status:0, sequence:0, packet_type:16, error:b'', rssi:0
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] STATUS code to command 0x0010:0
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Waiting for message 0x8010
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] RESPONSE 0x8010 - Version list : major:1, installer:30d, rssi:0, version:3.0d
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Stop waiting, got message 0x8010
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] REQUEST : 0x0021 b'\x03\x18\xc8\x00'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Msg to send b'00210004f60318c800'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Encoded Msg to send b'\x01\x02\x10!\x02\x10\x02\x14\xf6\x02\x13\x18\xc8\x02\x10\x03'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Waiting for status message for command 0x0021
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] RESPONSE 0x8000 - Status response : status:0, sequence:0, packet_type:33, error:b'', rssi:0
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] STATUS code to command 0x0021:0
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] REQUEST : 0x0023 b'\x00'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Msg to send b'002300012200'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Encoded Msg to send b'\x01\x02\x10#\x02\x10\x02\x11"\x02\x10\x03'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Waiting for status message for command 0x0023
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] RESPONSE 0x8000 - Status response : status:0, sequence:0, packet_type:35, error:b'', rssi:0
2018-08-22 22:18:25 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] STATUS code to command 0x0023:0
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Check network state
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] REQUEST : 0x0024
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Msg to send b'0024000024'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Encoded Msg to send b'\x01\x02\x10$\x02\x10\x02\x10$\x03'
2018-08-22 22:18:25 DEBUG (Thread-2) [zigate] Waiting for status message for command 0x0024
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] RESPONSE 0x8000 - Status response : status:0, sequence:0, packet_type:36, error:b'', rssi:0
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] STATUS code to command 0x0024:0
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] REQUEST : 0x0009
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Msg to send b'0009000009'
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Encoded Msg to send b'\x01\x02\x10\x02\x19\x02\x10\x02\x10\x02\x19\x03'
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Waiting for status message for command 0x0009
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] RESPONSE 0x8000 - Status response : status:0, sequence:0, packet_type:9, error:b'', rssi:0
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] STATUS code to command 0x0009:0
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Waiting for message 0x8009
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] RESPONSE 0x8009 - Network state response : addr:0000, ieee:00158d0001b258ef, pan:37366, extend_pan:11663107479473657577, channel:11, rssi:0
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Stop waiting, got message 0x8009
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] REQUEST : 0x0015
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Msg to send b'0015000015'
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Encoded Msg to send b'\x01\x02\x10\x15\x02\x10\x02\x10\x15\x03'
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Waiting for status message for command 0x0015
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] RESPONSE 0x8000 - Status response : status:0, sequence:0, packet_type:21, error:b'', rssi:0
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] STATUS code to command 0x0015:0
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Waiting for message 0x8015
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] RESPONSE 0x8015 - Device list : devices:[OrderedDict([('id', 0), ('addr', '9a79'), ('ieee', '00158d0001e55679'), ('power_type', 0), ('rssi', 92)]), OrderedDict([('id', 50), ('addr', 'c31c'), ('ieee', '84182600000d9ede'), ('power_type', 1), ('rssi', 131)])], rssi:0
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Known devices in zigate : {'c31c', '9a79'}
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Previous devices missing : set()
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_DEVICE_UPDATED
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Stop waiting, got message 0x8015
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Dispatch ZIGATE_DEVICE_UPDATED
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Check Need refresh Device c31c Plug 01
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Check Need refresh Device 9a79
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Need refresh : no type
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Dispatch ZIGATE_DEVICE_NEED_REFRESH
2018-08-22 22:18:26 DEBUG (Thread-2) [zigate] Auto saving /srv/homeassistant/conf/.zigate.json
2018-08-22 22:18:26 DEBUG (Thread-2) [custom_components.zigate] Add device Device c31c Plug 01
2018-08-22 22:18:26 DEBUG (Thread-2) [custom_components.zigate] Add device Device 9a79
2018-08-22 22:18:26 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sensor.zigate which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-08-22 22:18:26 DEBUG (Thread-5) [custom_components.sensor.zigate] Creating sensor for device Device 9a79  {'cluster': 1024, 'data': 0, 'unit': 'lm', 'value': 0, 'endpoint': 1, 'attribute': 0, 'name': 'luminosity'}
2018-08-22 22:18:26 DEBUG (Thread-5) [custom_components.sensor.zigate] Creating sensor for device Device 9a79  {'cluster': 1024, 'data': 65535, 'unit': 'lm', 'value': 65535, 'endpoint': 1, 'attribute': 1, 'name': 'min_value'}
2018-08-22 22:18:26 DEBUG (Thread-5) [custom_components.sensor.zigate] Creating sensor for device Device 9a79  {'cluster': 1024, 'data': 65535, 'unit': 'lm', 'value': 65535, 'endpoint': 1, 'attribute': 2, 'name': 'max_value'}

Everything work fine. An Osram switch appear, but don’t manage to use it. When I try to set if off, there is the following error in the log :

2018-08-22 22:20:07 DEBUG (Thread-8) [zigate] REQUEST : 0x0092 b'\x02\xc3\x1c\x01\x03\x00'
2018-08-22 22:20:07 DEBUG (Thread-8) [zigate] Msg to send b'009200064b02c31c010300'
2018-08-22 22:20:07 DEBUG (Thread-8) [zigate] Encoded Msg to send b'\x01\x02\x10\x92\x02\x10\x02\x16K\x02\x12\xc3\x1c\x02\x11\x02\x13\x02\x10\x03'
2018-08-22 22:20:07 DEBUG (Thread-8) [zigate] Waiting for status message for command 0x0092
2018-08-22 22:20:10 ERROR (Thread-8) [zigate] No response after command 0x0092

Even if I try to put the zigate in permit_join mode I have an error :

2018-08-22 22:25:06 DEBUG (Thread-7) [zigate] REQUEST : 0x0049 FFFC1E00
2018-08-22 22:25:06 DEBUG (Thread-7) [zigate] Msg to send b'0049000450fffc1e00'
2018-08-22 22:25:06 DEBUG (Thread-7) [zigate] Encoded Msg to send b'\x01\x02\x10I\x02\x10\x02\x14P\xff\xfc\x1e\x02\x10\x03'
2018-08-22 22:25:06 DEBUG (Thread-7) [zigate] Waiting for status message for command 0x0049
2018-08-22 22:25:09 ERROR (Thread-7) [zigate] No response after command 0x0049

I searched but don’t understand why it doesn’t work…
Can someone help me ?

Thanks in advance.


#108

Try to use the refresh_device service on your switch


#109

I tried but it doesn’t work. It’s weird because I have The same error with permit_join after 3 seconds.

No response after command...

Does it mean no response from zigate module ?
When I restart HA, zigate seems to respond correctly.


#110

You have response from your zigate:
2018-08-22 22:18:26 DEBUG (Thread-12) [zigate] Known devices in zigate : {‘c31c’, ‘9a79’}

This mean that you have two devices associated c31c and 9a79.
Do you have anything in your entity_registry.yaml?


#111

For the device ‘9a79’, I tried to pair a xiaomi motion sensor but don’t work neither.
There is components in entity_registry.yaml

zigate.895d:
  config_entry_id:
  name:
  platform: zigate
  unique_id: 84182600000d9ede
switch.zigate_895d_3:
  config_entry_id:
  name:
  platform: zigate
  unique_id: 84182600000d9ede-switch-3
sensor.zigate_9a79_min_value:
  config_entry_id:
  name:
  platform: zigate
  unique_id: 00158d0001e55679-1-1024-1
...

From what I understand, the zigate work and respond when HA start, then it doesn’t respond anymore to any command.

EDIT : I reset entity_registry.yaml and retry. Doesn’t work better, but encountered this error :

2018-08-23 16:13:28 DEBUG (Thread-9) [zigate] REQUEST : 0x0092 b'\x02\xc3\x1c\x01\x03\x00'
2018-08-23 16:13:28 DEBUG (Thread-9) [zigate] Msg to send b'009200064b02c31c010300'
2018-08-23 16:13:28 DEBUG (Thread-9) [zigate] Encoded Msg to send b'\x01\x02\x10\x92\x02\x10\x02\x16K\x02\x12\xc3\x1c\x02\x11\x02\x13\x02\x10\x03'
2018-08-23 16:13:28 DEBUG (Thread-9) [zigate] Waiting for status message for command 0x0092
Exception in thread Thread-12:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/srv/homeassistant/venv/lib/python3.5/site-packages/zigate/core.py", line 140, in _event_loop
    self.decode_data(packet)
  File "/srv/homeassistant/venv/lib/python3.5/site-packages/zigate/core.py", line 343, in decode_data
    struct.unpack('!HHB%dsB' % (len(decoded) - 6), decoded)
struct.error: bad char in struct format
2018-08-23 16:13:31 ERROR (Thread-9) [zigate] No response after command 0x0092

#112

FYI I have setup two osram plug like your recently and I also have issue with them.
They are working fine but if I restart hass the state is inverted (they were off then hass put them on and vice versa)

Here’s the complete log when I turn my plug on from hass

2018-08-25 21:57:48 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=switch, service=turn_on, service_data=entity_id=switch.lampe_dorian>
2018-08-25 21:57:48 DEBUG (SyncWorker_7) [zigate] REQUEST : 0x0092 b'\x02\xa8w\x01\x03\x01'
2018-08-25 21:57:48 DEBUG (SyncWorker_7) [zigate] Msg to send b'009200064a02a877010301'
2018-08-25 21:57:48 DEBUG (SyncWorker_7) [zigate] Encoded Msg to send b'\x01\x02\x10\x92\x02\x10\x02\x16J\x02\x12\xa8w\x02\x11\x02\x13\x02\x11\x03'
2018-08-25 21:57:48 DEBUG (SyncWorker_7) [zigate] Waiting for status message for command 0x0092
2018-08-25 21:57:48 DEBUG (Thread-3) [zigate] RESPONSE 0x8000 - Status response : status:0, sequence:29, packet_type:146, error:b'', rssi:0
2018-08-25 21:57:48 DEBUG (Thread-3) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-25 21:57:48 DEBUG (SyncWorker_7) [zigate] STATUS code to command 0x0092:0
2018-08-25 21:57:48 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]>
2018-08-25 21:57:48 DEBUG (Thread-3) [zigate] RESPONSE 0x8101 - Default device response : sequence:29, endpoint:3, cluster:6, cmd:1, status:0, rssi:117
2018-08-25 21:57:48 DEBUG (Thread-3) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-25 21:57:48 DEBUG (Thread-3) [zigate] RESPONSE 0x8102 - Individual Attribute Report : sequence:11, addr:a877, endpoint:3, cluster:6, attribute:0, status:0, data_type:16, size:1, data:True, rssi:117
2018-08-25 21:57:48 DEBUG (Thread-3) [zigate] Dispatch ZIGATE_RESPONSE_RECEIVED
2018-08-25 21:57:48 DEBUG (Thread-3) [zigate] Dispatch ZIGATE_ATTRIBUTE_UPDATED
2018-08-25 21:57:48 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.lampe_dorian, old_state=<state switch.lampe_dorian=off; addr=a877, endpoint=3, battery_voltage=None, battery_level=100, friendly_name=Lampe Dorian @ 2018-08-25T21:56:38.055695+02:00>, new_state=<state switch.lampe_dorian=on; addr=a877, endpoint=3, battery_voltage=None, battery_level=100, friendly_name=Lampe Dorian @ 2018-08-25T21:57:48.757893+02:00>>
2018-08-25 21:57:48 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=zigate.lampe_dorian, old_state=<state zigate.lampe_dorian=2018-08-25 21:56:38; battery_voltage=None, battery_level=100, rssi_percent=44, type=Plug 01, manufacturer=bbaa, receiver_on_when_idle=True, missing=False, addr=a877, bit_field=0100000000000001, descriptor_capability=00000011, id=54, ieee=7cb03eaa00b19eef, last_seen=2018-08-25 21:56:38, mac_capability=10001110, max_buffer=64, max_rx=0, max_tx=0, power_type=1, rssi=111, server_mask=0, friendly_name=Device a877 Plug 01, icon=mdi:access-point @ 2018-08-25T21:56:38.057761+02:00>, new_state=<state zigate.lampe_dorian=2018-08-25 21:57:48; battery_voltage=None, battery_level=100, rssi_percent=46, type=Plug 01, manufacturer=bbaa, receiver_on_when_idle=True, missing=False, addr=a877, bit_field=0100000000000001, descriptor_capability=00000011, id=54, ieee=7cb03eaa00b19eef, last_seen=2018-08-25 21:57:48, mac_capability=10001110, max_buffer=64, max_rx=0, max_tx=0, power_type=1, rssi=117, server_mask=0, friendly_name=Device a877 Plug 01, icon=mdi:access-point @ 2018-08-25T21:57:48.760200+02:00>>

#113

Ok now my plug are running fine, the problem was in my nodered setup…
I’ve completely reset my installation on the hass side by deleting .zigate and entity_registry.yaml and now everything works as expected ( thanks for your work @doudz )

Did you tried that @bdr ?


#114

I am wondering how long this component will be compatible with home assistant without any updates? :frowning:


#115

zigate itself isn’t getting a lot of updates.
opensourcing the zigate fw would allow new users/developpers to join this community.


#116

The source are coming but I think the main issue for zigate is that the stick is not available outside of Europe.


#117

zigate uses nxp jn5168, some aqara devices uses nxp jn5169. I think it would be possible to hack an aqara device and use it as a zigbee coordinator. ( https://github.com/fairecasoimeme/ZiGate/issues/17 https://hackaday.io/project/20321-xiaomi-mi-smart-sensor-hack#menu-description )
that might be a reason why the fw is not opensource.


#118

@lolorc creator of zigate have planned to release the firmware on GitHub, probably by the end of the year.

@dziugasp Actually i’m busy, but I need to keep the compatibility of this component because I use it in my home and all my home extension lights was driven by wireless switch. So I will personally maintain it.


#119

future will tell, in the mean time I’ve moved to zigbee2mqtt :slight_smile:


#120

I paired a IKEA Tradfri dimmable lightbulb to Zigate but appears as an unknown device “zigate.1347”.
Is there anything I can do to make work as a light?

Edit: After a few restarts of Hass it works as it should!


#121

Yes, I don’t know exactly why but sometimes you need to restart hass to complete the pairing of a new device.

FYI I migrate my docker container to version 0.77.3 and the component continue working fine.