Hi,
I built a mysensors-node that has an infrared receiver. My goal is it to start different appdaemon-scripts depending on the button pressed.
I subscribed to the event like this
self.listen_event(self.cb_ir_signal_received, entity_id=self.ir_sensor, attribute='V_IR_RECEIVE')
This works fine in so far that my callback is called every time I press a button my tv remote. The problem is though that sometimes random events are recorded too.
This is the data that my callback-function received when I pressed the volume up button on the remote:
2020-03-03 21:50:06.888588 INFO Living_Room_IR: {'entity_id': 'sensor.mysensors_wohnzimmer_main_3_3', 'old_state': {'entity_id': 'sensor.mysensors_wohnzimmer_main_3_3', 'state': '34468875', 'attributes': {'battery_level': 24, 'heartbeat': 0, 'child_id': 3, 'description': '', 'device': '/dev/ttyUSB0', 'node_id': 3, 'V_IR_RECORD': '624502100', 'V_IR_RECEIVE': '34468875', 'friendly_name': 'mysensors_wohnzimmer_main 3 3'}, 'last_changed': '2020-03-03T20:48:42.243478+00:00', 'last_updated': '2020-03-03T20:48:42.243478+00:00', 'context': {'id': '4581e942ffd14197a76d68eeb2e8f1ca', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.mysensors_wohnzimmer_main_3_3', 'state': '34468875', 'attributes': {'battery_level': 23, 'heartbeat': 0, 'child_id': 3, 'description': '', 'device': '/dev/ttyUSB0', 'node_id': 3, 'V_IR_RECORD': '624502100', 'V_IR_RECEIVE': '34468875', 'friendly_name': 'mysensors_wohnzimmer_main 3 3'}, 'last_changed': '2020-03-03T20:50:06.842323+00:00', 'last_updated': '2020-03-03T20:50:06.842323+00:00', 'context': {'id': '1c8dbbe19ef841c5aa1f77c35558939c', 'parent_id': None, 'user_id': None}}}
And that’s exactly as expected, the problem is that my callback was called with this data a minute later when nothing was pressed:
2020-03-03 21:51:31.405484 INFO Living_Room_IR: {'entity_id': 'sensor.mysensors_wohnzimmer_main_3_3', 'old_state': {'entity_id': 'sensor.mysensors_wohnzimmer_main_3_3', 'state': '34468875', 'attributes': {'battery_level': 23, 'heartbeat': 0, 'child_id': 3, 'description': '', 'device': '/dev/ttyUSB0', 'node_id': 3, 'V_IR_RECORD': '624502100', 'V_IR_RECEIVE': '34468875', 'friendly_name': 'mysensors_wohnzimmer_main 3 3'}, 'last_changed': '2020-03-03T20:50:06.842323+00:00', 'last_updated': '2020-03-03T20:50:06.842323+00:00', 'context': {'id': '1c8dbbe19ef841c5aa1f77c35558939c', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.mysensors_wohnzimmer_main_3_3', 'state': '34468875', 'attributes': {'battery_level': 24, 'heartbeat': 0, 'child_id': 3, 'description': '', 'device': '/dev/ttyUSB0', 'node_id': 3, 'V_IR_RECORD': '624502100', 'V_IR_RECEIVE': '34468875', 'friendly_name': 'mysensors_wohnzimmer_main 3 3'}, 'last_changed': '2020-03-03T20:51:31.369682+00:00', 'last_updated': '2020-03-03T20:51:31.369682+00:00', 'context': {'id': 'ed8d927ffac548c3bdfb583b62822582', 'parent_id': None, 'user_id': None}}}
As you can see the timestamps differ so I can’t use that to filter out random calls of the callback funcrtion. I checked the entity in lovelace and it doesn’t show those random calls to the callback function, i.e. if I press the button now and don’t touch it for 2h the card will show that it has been in that state for two hours.
Can anybody see what I am doing wrong here? Do I need a different parameter in my listen_event
-function?