Hi there,
i tried to reset/edit the state of this sensor.
sensor:
- platform: history_stats
name: Test Flips
entity_id: binary_sensor.openclose_10 #The aqara sensor
state: 'off'
type: count
start: '{{ now().replace(hour=0, minute=0, second=0) }}'
end: '{{ now() }}'
Actual State :“10”
-
I tried to set the state of this sensor via Devtools/State/SET STATE to “1”
That worked and is reflected in the UI, but the state is updated back to “10” after some seconds or at the next update of this sensor. -
I tried to edit the state via databse (edited via state table). Deleted all old values from “statistics” and “statistics_short_term” for this entity.
That is not reflected in the ui. Sensor gets updates after some seconds or at the next update of this sensor back to “10”.
I also tried to stop HA completely when i do the changes in the Databse, but after restarting HA, the state gets set back to old value.
So my question:
Can someone explain to me, where the Value of “10” is stored in the databse?
Whats the best practice to edit those Values?
edit:
Example of Events Output after i set the state via Devtools to “1” and triggert the opensclose sensor.
Where is the “pre value” saved?
cant find it
{
"event_type": "state_changed",
"data": {
"entity_id": "sensor.test_flips",
"old_state": {
"entity_id": "sensor.test_flips",
"state": "1",
"attributes": {
"state_class": "measurement",
"unit_of_measurement": "",
"device_class": "duration",
"icon": "mdi:chart-line",
"friendly_name": "Test Flips"
},
"last_changed": "2022-08-02T09:59:40.625905+00:00",
"last_updated": "2022-08-02T09:59:40.625905+00:00",
"context": {
"id": "01G9EZYBAH7FYR3AM5TW5Y99FX",
"parent_id": null,
"user_id": "54bff3c13dd445658793d488c000e082"
}
},
"new_state": {
"entity_id": "sensor.test_flips",
"state": "11",
"attributes": {
"state_class": "measurement",
"unit_of_measurement": "",
"device_class": "duration",
"icon": "mdi:chart-line",
"friendly_name": "Test Flips"
},
"last_changed": "2022-08-02T09:59:42.774741+00:00",
"last_updated": "2022-08-02T09:59:42.774741+00:00",
"context": {
"id": "01G9EZYDDP445CQ1WDWYCZTMGS",
"parent_id": null,
"user_id": null
}
Debug logs show following: (see old_state=<state sensor.test_flips=10 )
Cant find this DB entry
2022-08-02 12:27:24 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event state_changed[L]: entity_id=sensor.test_flips, old_state=<state sensor.test_flips=10; state_class=measurement, unit_of_measurement=, device_class=duration, icon=mdi:chart-line, friendly_name=Test Flips @ 2022-08-02T12:25:47.933074+02:00>, new_state=<state sensor.test_flips=1; state_class=measurement, unit_of_measurement=, device_class=duration, icon=mdi:chart-line, friendly_name=Test Flips @ 2022-08-02T12:27:24.891774+02:00>>)
Thank you for your help