Closed rct closed 10 months ago
Hey there @fabaff, mind taking a look at this issue as it has been labeled with an integration (threshold
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
threshold documentation threshold source (message by IssueLinks)
Hey there @rytilahti, @thegardenmonkey, mind taking a look at this issue as it has been labeled with an integration (tplink
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
tplink documentation tplink source (message by IssueLinks)
If the threshold entity is based on an entity that changes frequently, like power consumption or temperature, this can generate a lot of rows in the recorder DB.
It's possible in recorder
to exclude certain elements from being logged.
I have a threshold monitor to keep track of mains electricity supply ("Eskom Supply"). If the supply goes, then the pond pump must turn off to conserve battery.
The routine is being triggered every couple of seconds:
This is in spite of the state of the sensor not changing:
This seems to run contrary to monitoring state changes in other sensors which reflect changes only when state changes rather than when state is checked.
If the threshold entity is based on an entity that changes frequently, like power consumption or temperature, this can generate a lot of rows in the recorder DB.
It's possible in
recorder
to exclude certain elements from being logged.
Assuming by elements you mean entities?
I could be wrong, however it seems the threshold sensor itself would have to be excluded from recorder. And the bulk of the space in the recorder DB is from the threshold sensor's attributes which record the state of the checked entity every time it changes.
Excluding threshold sensors from the recorder requires both editing YAML and a Home Assistant restart. So if one is going to wind up having to do all of that, then it would just be better to define your own template binary sensor and avoid the threshold sensor.
One further thing I've noticed - because of the constant triggering of the threshold sensor in my automation, I can no longer turn on the pump manually outside of the scheduled time without first disabling the automation.
Surely the threshold sensor should differentiate when it is "updated" vs when it is "changed"? The automation suggests that it requires the threshold sensor to "change" ("on" to "off", or vice versa). Currently, it appears to trigger whenever the sensor is "updated."
I also have an issue with this behavior as it constantly writes entries to the states DB table. I have added the threshold sensor to the recorder on purpose and have thousand of rows in the DB although the state of this sensor never changed.
Wouldn't it be valid to change this behavior to just record changed values? I believe this is the case in other parts, like a template binary sensor which reacts on frequent changes of another entity...
@fabaff - in the 5+ months this issue has been opened, you've only made a single comment--to exclude threshold from recorder.
Do you feel the current behavior is appropriate and disagree with the issues people have raised here?
Add me to the list of people having issues with this...
My automation gets triggered every time the entity that the threshold helper is based on changes, even if the helper it self isn't changed. Filling up the logs...
I have the same problem. Threshold based on sun azimuth, used as automation trigger - gets triggered on every azimuth change (which is a lot!) though the threshold state hasn't changed..
So if one is going to wind up having to do all of that, then it would just be better to define your own template binary sensor and avoid the threshold sensor.
This.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
I need to test on 2023.9, but I don't think this ever got fixed. I've changed any threshold sensors over to binary template sensors.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
The problem
The threshold integration appears to generate a state update and a shared attribute update each time the source entity the threshold is based on changes. This occurs even if the threshold entity itself does not change.
When the source entity changes, it's value is saved as the attribute
sensor_value
for the threshold entity.If the threshold entity is based on an entity that changes frequently, like power consumption or temperature, this can generate a lot of rows in the recorder DB.
While this might be useful for debugging the threshold sensor, the data for the source entity is presumably already stored in recorder. So adding a threshold sensor multiplies the number of updates to recorder.
From a UX perspective, in can be surprising that a threshold helper might contribute to DB growth even if the threshold entity rarely changes.
Related community thread and comment from bdraco: https://community.home-assistant.io/t/threshold-helper-update-rate-db-size-state-rows/479192/5?u=rct
What version of Home Assistant Core has the issue?
2022.10.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
Threshold
Link to integration documentation on our website
https://www.home-assistant.io/integrations/threshold/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
The use case for the threshold sensor is to monitor power usage, via a TPLink HS110 (built in TP Link Kasa Smart integration), and alert/take action if the power usage is below the expected range (eg the device has been powered off or has malfunctioned.)
The source entity for the threshold sensor is
sensor.devicename_current_consumption
from the TP-Link Kasa Smart integration. That entity is updating every 20 seconds.The threshold sensor itself has not changed state during the history of recorder DB, other than for Home Assistant restarts.
The
states
table rows for the threshold sensor:The
shared_attr
data written to thestate_attributes
table:(Note that
sensor_value
is the only attribute that is changing if the threshold hasn't been crossed.