doudz / homeassistant-zigate

zigate component for Home Assistant
MIT License
48 stars 15 forks source link

Issue with Xiaomi Aqara button single click #42

Closed DrJackal closed 5 years ago

DrJackal commented 5 years ago

Hello, I'm having trouble to use the Xiaomi Aqara buttun (ref:WXKG11LM) with your application. The double and tripe click works fine but the single click is ofter not seen. I’m wordering if it’s not due to a backend task of AppDaemon which is looking for states changes and as the single click is a quick double state change (off->on->off), it doesn’t not always see it. On home assistant, the event is easelly seen.

Here my code, it is basic, just for testing : import appdaemon.plugins.hass.hassapi as hass

class test(hass.Hass):

def initialize(self):
    self.log("Initialisation of class 'test'")
    self.handle_sensor_callback = self.listen_state(self.sensor_callback, "binary_sensor.zigate_00158d0002130dd6_onoff")

def sensor_callback(self, param1, param2, param3, param4, kwargs):
    self.log("DEBUG: sensor_callback single click")

Is there any way to correct this on Appdaemon or your lib please? let me know if you need any information. Thanks for your help. Max

doudz commented 5 years ago

I don't know how Appdaemon works, but for single click in automation it's better to listen to event "zigate.attribute_updated" instead of the binary sensor

DrJackal commented 5 years ago

Ok I will try this, thanks! Max

DrJackal commented 5 years ago

I did not found any trigger named "ZiGate.attribute_updated". In the mid time I updated my zigate and now I see events correctly. However I don't see the data parameter in home assistant (with debug logs) : https://zigate.fr/le-materiel-compatible-zigate/compatible/boutonaqara/ : When one click, there are 2 events for push and release and a "attribute data" shall be updating but I don't see it in home assistant logs, is it normal ?

biau commented 5 years ago

Don't you have something like this ? image I'm using this event with a double key wireless switch and nodered. It's running fine.

DrJackal commented 5 years ago

I found it and I tried it, it works perfectly now ! Thank you.