Hi all,
I have an issue with a state automation triggering when it should not. The scenario is this:
I have a TPLink HS110 switch with metrics as sensors. It’s connected to a laundry dryer. The sensor is defined as follows:
- platform: template
sensors:
tp_link_watts:
value_template: '{{ states.switch.tplink_hs110.attributes["current_consumption"] | replace(" W", "") | float }}'
And the automation trigger is this:
- alias: 'notify on dryer finished'
id: notify_on_dryer_finished
initial_state: true
hide_entity: false
trigger:
platform: numeric_state
entity_id: sensor.tp_link_watts
below: 30
for:
minutes: 5
action:
…
This works nicely and does inform me when my dryer is finished.
However, it happened to me twice within a couple of days that I got false alarms. Usually the watts sensor is at 0W, but occasionally it seems to go up to 0.3W, just to return to 0W for the next reading. I checked the HA DB for the state changes:
select * from states where entity_id like '%watts%' order by created desc limit 3;
state_id | domain | entity_id | state | attributes | event_id | last_changed | last_updated | created
----------+--------+----------------------+---------+-----------------------------------------------------------------------------------------------+----------+-------------------------------+-------------------------------+-------------------------------
486038 | sensor | sensor.tp_link_watts | 0.0 | {"friendly_name": "tp_link_watts", "icon": "mdi:washing-machine", "unit_of_measurement": "W"} | | 2017-11-14 14:35:22.541915+01 | 2017-11-14 14:35:22.541915+01 | 2017-11-14 13:35:22.589673+01
486034 | sensor | sensor.tp_link_watts | 0.3 | {"friendly_name": "tp_link_watts", "icon": "mdi:washing-machine", "unit_of_measurement": "W"} | | 2017-11-14 14:34:51.57865+01 | 2017-11-14 14:34:51.57865+01 | 2017-11-14 13:34:51.629888+01
479664 | sensor | sensor.tp_link_watts | 0.0 | {"friendly_name": "tp_link_watts", "icon": "mdi:washing-machine", "unit_of_measurement": "W"} | | 2017-11-13 22:40:45.845699+01 | 2017-11-13 22:40:45.845699+01 | 2017-11-13 21:40:48.798226+01
So it was really just one reading that went above 0W. Yet, it fired the notification. I wonder if my yaml is wrong in some place or if automation triggers with thresholds (below/above) have some issues. My understanding would be that “below: 30” would not match state changes from a value below 30 to a value below 30, but only state changes crossing the threshold value?
Thanks for any help!
baf