Closed Ernst79 closed 1 year ago
Should fix https://github.com/home-assistant/core/issues/95892
@bdraco I'm not sure if this is the most clean way to fix this issue, possibly it should be fixed in sensor-state-data instead. What happens is that if no event is fired (e.g. only a battery update), it has the old event in memory (in self._events_updates
) and it is fired on each subsequent sensor update here
https://github.com/Bluetooth-Devices/sensor-state-data/blob/57d6ee07694c9a4f967b06af611227527db7fd88/src/sensor_state_data/data.py#L195C20-L195C20
I feel a bit uncomfortable changing code in sensor-state-data, so I leave that up to you to decide.
Yes, that is probably much better. I’ll update this PR after sensor-state-data is released. Thanks for the quick fix!
Should be good to rebase now
Patch coverage: 100.00
% and no project coverage change.
Comparison is base (
74b38b7
) 77.28% compared to head (54556a3
) 77.28%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@bdraco It looks like sensor-state-data 2.16.1 does not fix the issue somehow. I'll have to look into it further tonight, but the last bthome test that is added in this PR is a test with a button event, followed by event = {}
. But it still shows the old result on the second event, despite the fix. I'll look into it further tonight, but something seems still wrong.
@bdraco I had a look why the event is still there after the update, and I found out that the update()
function bthome_ble is using is defined in bluetooth_sensor_state_data
. bluetooth_sensor_state_data
is refering to SensorData
from sensor_state_data
, but both have an update()
function. The one of bluetooth_sensor_state_data
is being used in the end.
That is why the clearing of the events in the same update()
function in sensor_state_data
is not used in my bthome test example. What would be the correct way to fix this? Adding the same self._events_updates.clear()
in bluetooth_sensor_state_data
?
@bdraco I had a look why the event is still there after the update, and I found out that the
update()
function bthome_ble is using is defined inbluetooth_sensor_state_data
.bluetooth_sensor_state_data
is refering toSensorData
fromsensor_state_data
, but both have anupdate()
function. The one ofbluetooth_sensor_state_data
is being used in the end.That is why the clearing of the events in the same
update()
function insensor_state_data
is not used in my bthome test example. What would be the correct way to fix this? Adding the sameself._events_updates.clear()
inbluetooth_sensor_state_data
?
Right. I forgot we override that for the Rssi sensor and we don't call super() because we need specific order
Best solution right now is the same exact change in bluetooth_sensor_state_data
as you suggest above
Thanks, that fixed it.
fix: fix for repeated events (fix #75)