Another component for ZiGate


#1

I announce the avaibility of a new (custom) component to use the zigate (http://www.zigate.fr)

Unlike the one made by elric91, my component automatically create entities, just like the zwave component, (and it use a different python lib to interact with the ZiGate, the same used by the jeedom plugin)

More information on github :

it support sensor and binary_sensor, switch and light (onoff, brightness, color)

ZiGate is an universal gateway compatible with a lot of ZigBee device (like Xiaomi, Philipps Hue, Ikea, etc)


One Zigbee gateway to rule them all?
New custom component : ZiGate
#2

Now switch is supported


#3

Can you summarize the end user differences between yours and elric91 component ?
To elaborate a little bit: I have roughly 20 sensors and switches paired with zigate through elric91 component with some changes for events generation. Is there a reason why would I consider switching ? The auto generation of entries sounds great, but is there more than it ?


#4

The differences are :

  1. Easier configuration

just put the following in your configuration.yml (the port will be auto-discovered)

zigate:

or you could specify the usb port

zigate:
  port: /dev/ttyS0

Entities (sensor, switch, etc) will be auto-generated
The zigate wifi is supported but disabled because the wifi module is buggy, see https://github.com/fairecasoimeme/ZiGate/issues/45

  1. based on a different python lib https://pypi.org/project/zigate/ already used on the zigate jeedom plugin daily used by around 100 people.

  2. use some kind of discovery system internally so almost any kind of zigbee component could be supported, already tested many Xiaomi items, Ikea bulbs, Philipps Hue bulbs, Osram bulbs, Profalux covers, Heiman sensors.

  3. currently use threads instead of asyncio


#5

Thanks for your work!
Actually I mainly have 4 aqara wall switch with double key and one tradfri buble.
Every wall switch is discovered and so the tradfri bulb.

Switches are created on my dashboard it’s great but I’ve noticed that endpoint 02 is not working correctly on all wall switches. Turn ON one time then never turn off or on again.

My tradfri bulb is displayed like a switches.

My aqara wireless dual switch is not detected at all. (I can see the blue zigate led changing intensity that means that the zigate see the click but nothing in ha logs).

Finally I have a aqra cube in his box but I don’t know if you support it.

Thanks again !


#6

Thanks for testing !

I just push a small fix for switch so now the endpoint 02 should works, I hope.
About the tradfi bulb, as I said I have not write the light platform that’s why it’s displayed as switch

about the aqara wireless, it’s a bit strange, I’ll check
And about the cube it’s supported but I ordered one to finalize the correct decoding, not yet received


#7

Does it mean the device doesn’t show up in zigate device list ? or just binary_sensor are missing ?
Are you sure the device is paired with the zigate (sometimes zigate just lose equipements, probably a firmware bug)


#8

I will retry as soon as I can because I had to return to elrich config for the evening :blush:
But I even tried to pair again the wireless dual switch but nothing showed in HA. And nothing in the logs. As soon as I revert to elrich custom component the switch worked as before, just had to update the short address because of the new pairing.


#9

oh really ? it’s really strange, I could understand binary sensors are missing but the device should appear in the device list.
is it a lumi.sensor_86sw2 ?

In any case, thanks again for testing


#10

I added some logging to help debugging
To see the log, set level to debug

logger:
  default: debug

or

logger:
  logs:
    custom_components.zigate: debug
    custom_components.switch.zigate: debug
    custom_components.sensor.zigate: debug
    custom_components.binary_sensor.zigate: debug

If you want to see debug information from zigate, add the following too

logger:
  logs:
    ...
    zigate: debug

#11

Add light support (only brightness currently)


#12

ok I try you component again.
Actually I have two switches completely recognized after second HA restart.
Remaining two others wall switches + wireless switch and ikea bulb are recognized but not created as switches and light.
Tried to reboot but now looks like I have issues with my SD card on my pi.
Maybe it did not like the debug mode.

Here’s one error I was able to see:

2018-07-04 20:08:42 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform zigate
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/light/zigate.py", line 72, in setup_platform
    sync_attributes()
  File "/home/homeassistant/.homeassistant/custom_components/light/zigate.py", line 67, in sync_attributes
    entity = ZiGateLight(device, endpoint)
  File "/home/homeassistant/.homeassistant/custom_components/light/zigate.py", line 93, in __init__
    if action_type == zigate.ACTION_LEVEL:
NameError: name 'zigate' is not defined

#13

Now I tried a fresh start by deleting the persistent file: /home/homeassistant/.homeassistant/zigate.json
After a restart nothing shown on my dashboard and only one device with no endpoint in config.
Second restart, I have two switches working again but not the same :smiley:
Looks like there’s 4 devices for a total of 8 switches but he stop after 4.
Light and wireless still not working.
persistent file : http://termbin.com/lck8
logs : http://termbin.com/oduh

working devices are :
addr: 409c endpoint: 2
addr: 84c3 endpoint: 1
addr: cef7 endpoint: 1
addr: cef7 endpoint: 2


#14

Oops, my github was not up to date… that’s why light just failed, I’m sorry
I pushed the fix this morning, this will probably fix your wireless switch problem too

Deleting the persistent file is always a bad thing, some information can only be retrieve at pairing time or by asking a refresh and/or pushing the pairing button on XIAOMI devices to wakeup them.

Some missing entities could appear when their states change too, that’s why a completly unknown device could works because of the discovery system

Thanks again for testing.
Since I have no real bulb to test (not yet received) I didn’t see the mistake


#15

Do you mean that you do not officially support devices that are already paired to the zigate when you start the component for the first time?


#16

Devices already paired are supported, the system tries to discover their capabilities and then create according entities (sensor, switch, etc) but since devices running on battery sleep most of the time this discovery could not happen, because the device doesn’t answer. So the system will create entities only when the device talk to zigate.
For other device like bulbs, it’s not a problem because they are always listening so the discovery works.

At pairing time, device running on battery listen during few seconds so the discovery full works.

This discovery is called a refresh, you can call the service zigate.refresh_device to force a device refresh, you have to set the addr.
Example :

service : zigate.refresh_device
data:
  addr: ab01

Typically if you want to refresh a XIAOMI device running on battery you have to push the small pairing button one or more times just after calling the refresh in order to wakeup the device so it can answer to requests.


#17

So it could explain my issue with wireless switch but not with the wall switch?
How can I try recover my four missing endpoints?


#18

I think everything is ok now, but if you want to be sure, just wait a little I just received my OSRAM bulb :wink:


#19

I’ve quickly setup a new hassbian install yesterday on a USB stick and now my ikea bulb is detected.
As you saied no on off state only brightness for the moment.
All my devices not on batteries are recognized I’ve only one of the wall switch were endpoint 2 was not listed. I was testing on my phone at that moment so I need to investigate deeper.
I also have notification for devices on battery which need to be refresh that’s great.
Thanks a lot for your work here.


#20

I just made some adjustement this morning, now light works, supported features are onoff state, brightness and hue color