Hello people, it is probably me but I am struggling with the differences between platform trigger state and numeric_state.
What I am trying to do is to turn on the switch for a a set of Sonoff Relays if I detect the temperature of that respective sensor to be below x for 30 mins.
I would like to have 1 automation to do this for multiple similar devices, ideally. Please tell me if this cannot be done and advice on best option. Thank you.
For State - The below works but I would like a range of temperature below x for example and not a point value.
alias: "Rogue AM Air-Con Temp State Change"
description: ""
trigger:
- platform: state
entity_id:
- sensor.sonoff_10005bba3c_temperature
- sensor.sonoff_10011fffb4_temperature
id: Temperature_Change
to: "28" # I need < 28 but dont think this can be done here
for:
hours: 0
minutes: 30
seconds: 0
condition:
- condition: time
before: "07:00:00"
after: "05:00:00"
action:
- service: >-
switch.turn_{{ 'on' if states(trigger.entity_id)|float(0) < 28.0 else
'off' }}
data: {}
target:
entity_id: >-
{{ trigger.entity_id|replace('sensor', 'switch')|replace('_temperature',
'') }}
mode: single
For Numeric_State - The below looks ok to set a temperature below x for example for 30 mins for example but nothing gets triggered for multiple entities. Not sure what I am doing wrong.
Here you can only trigger on matching exact states, like a single numeric value, or âoffâ or âonâ etc⌠You can match on the state changing to an exact state or from an exact state. You can also trigger on changing to any state by leaving to: as null (blank).
Thanks @tom_l I have read those docs over and over again.
So it seems like what I want to do, I cannot use the state trigger since I need a range of numeric values (< 28.0). I tried the numeric_state as like both my similar code snippets showed but it does not seem to trigger. I am not sure if it supports multiple entities as it does not trigger.
So in a dilemma, looks like there is no one single automation trigger to do what I want it to do ?
Thanks @tom_l . Looks like it started to trigger when I remove the ââ (string) quotes from the Above parm. I will do further testing and update. Thank you !
Yes and it doesnât matter if the numeric value of above or below is wrapped in quotes (the Numeric State Trigger handles it as a number, not a string).
In order for the automation to trigger, the value of either of the two temperature sensors must decrease from above the threshold of 28 to below the threshold. Itâs the crossing of the threshold that causes the trigger.
In addition, once it has crossed the threshold it must remain below it for at least 30 minutes (never even once rising above the threshold otherwise the 30-minute countdown is cancelled and the trigger is reset).
Finally, all of this must happen during a specific 2-hour window (05:00-07:00) in order to execute the automationâs action. For example, if the temperature drops below 28 at 06:45 and remains below 28 for 30 minutes, it wonât execute the actions at 07:15 because thatâs outside the 2-hour window.
If thereâs no trace then none of the requirements I described were met.