doudz / homeassistant-zigate

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

Xiaomi devices change state every 50 minutes #78

Closed arkpoah closed 4 years ago

arkpoah commented 4 years ago

Hello,

I'm using a Xiaomi Aqara single button and I created an automation to use it :

- alias: 'bouton spots cuisine'
  trigger:
    platform: state
    entity_id: zigate.00158d000214f0ad
  action:
    service: switch.toggle
    entity_id: switch.qubino_goap_zmnhadx_flush_1_relay_switch

This works fine, the state changes when I push button and automation is triggered.

The issue is that the state changes alone every 50 minutes, is there something sent to device every 50min ? I have no more automation wich could interact with it. I see same behavior with my Xiaomi door sensor.

I use Zigate Wifi with 3.1a firmware.

Thanks

arkpoah commented 4 years ago

I use the device entity because binary_sensor does not work with the button : #79

bokub commented 4 years ago

If you don't care about the multiclic, you can use an event trigger (instead of state).

The event to listen is zigate.attribute_updated

arkpoah commented 4 years ago

zigate.attribute_updated event works fine but it is triggered for all zigate devices ^^ When I try to filter on one entity, it does not work anymore, I do it like that :

- alias: 'Allumer/Eteindre spots cuisine'
  trigger:
    - platform: event
      event_type: zigate.attribute_updated
      event_data:
        entity_id: binary_sensor.zigate_00158d000214f0ad_onoff
  action:
    service: switch.toggle
    entity_id: switch.qubino_goap_zmnhadx_flush_1_relay_switch

Do I miss something ?

biau commented 4 years ago

The entity_id is the zigate entity so zigate.000158d000214f0ad for you.

arkpoah commented 4 years ago

yes I tried that first but same behavior

biau commented 4 years ago

I can't provide an example because I'm using nodered for automation but here's what I can see in the payload of an attribute_update event:

{"event_type":"zigate.attribute_updated","entity_id":"zigate.00158d0002d7bb59","event":{"endpoint":1,"cluster":6,"addr":"7376","attribute":0,"data":true,"name":"onoff","type":"bool","value":true,"ieee":"00158d0002d7bb59","device_type":"lumi.relay.c2acn01","entity_id":"zigate.00158d0002d7bb59"}}

bokub commented 4 years ago

I'm not at home right now so I can't confirm, but I think you need to filter on value: true. Otherwise, you'll receive 2 events, one when you press and one when you release the button, which will toggle your lights 2 times.

Also, your entity_id is zigate.00158d0002d7bb59, not anything else

arkpoah commented 4 years ago

Ok it works fine, I think I done a typo to zigate_ instead of zigate. Thx !

arkpoah commented 4 years ago

anyway, issue is still there, every 50 minutes, state is auto updated and event attribute_updated is triggered...

biau commented 4 years ago

Do you filter value in the event ? Because maybe your device is just reporting attributes.

You should filter on event.cluster = 6 and event.value = true

bokub commented 4 years ago

Here is the trigger I use for my automation, and it works perfectly:

trigger:
  - platform: event
    event_type: zigate.attribute_updated
    event_data:
      entity_id: zigate.xxxxxxxxxxxx
      name: onoff
      value: true
arkpoah commented 4 years ago

I confirm it works correctly with more filters, thx.