wernerhp / ha.appdaemon.aqara_motion_sensors

An AppDaemon app to reset Xiaomi Aqara motion sensors after a given timeout.
MIT License
40 stars 5 forks source link

Suggestion about making the code more global for working with ZHA, too #9

Closed Bascht74 closed 2 years ago

Bascht74 commented 3 years ago

Hi,

your appdaemon script doesn't work with ZHA, only the aqara integration.

But if you change:

    for entity_id in motion_sensors:
#     self.listen_event(self.motion_sensor_state_on, "xiaomi_aqara.motion", entity_id=entity_id)
      self.listen_state(self.motion_sensor_state_on, entity_id, new = "on")

# def motion_sensor_state_on(self, event, data, kwargs):    
  def motion_sensor_state_on(self, entity, attribute, old, new, kwargs):
    """Set motion sensor state to on"""
    entity_id = entity

it should probably work globally. I can say that this works with ZHA, could you please test it with the aqara integration. If it works, too, you could think about changing those three lines in your code...

Seb

Bascht74 commented 3 years ago

@wernerhp could you pleas look into that as it might help others a lot with a little change...

Thx!

wernerhp commented 2 years ago

I've migrated away from the Aqara hub, so I can't test for regressions, but I've released a new version that supports ZHA.