Another component for ZiGate

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 !

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

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)

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.

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

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

Add light support (only brightness currently)

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

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

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

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?

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.

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

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

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.

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

1 Like

Brightness works fine as before.
I can turn off light with the switch but the state in HA does not turn off.
After that only way to turn on is to change brightness.

Ok now I’ve my bulb, my four wall switches but the wirelless stil not show . (44a9)
Don’t know why I have e7d9
image
image

About the bulb problem, are you sure you use the last version from my git ?

About the Switch it’s strange, Can I have the persistent file zigate.json ?
You said it doesn’t show what do you mean? the binary sensor has been created

Yes I’ve clone your repository in custom_components.
Git pull says it’s up to date.
I had the exact same behavior with Elrich component and my switches before.
The light turns off and then report on to HA so HA reset the state to on even if switch was off.

Here’s my zigate.json: http://termbin.com/c5sw
Binary sensor is created, but no switch.
And strange there’s no zigate.44a9 entity.
Only zigate.e7d9 with addr attribute to 44a9 as shown in my capture before.

Maybe I’m wrong but I think it’s normal there’s no switch because you cannot drive it.
It’s different than wall switch.

To me, you can only push the button with your finger and get the information on the binary_sensor in Hass