Using a threshold is not what I need but as the title says: I’m looking for a way to use a trigger when the temperature rises again after it has been dropping.
The gradient
attribute of a Trend sensor returns a negative value while the source sensor’s value is falling and a positive when rising. Depending on the source, it’s may need some smoothing to get a reliable output that could be used with a numeric state trigger.
Not exactly the same, but a similar topic
I didn’t see how to quite do that with trend. I could be missing something.
but shouldn’t be hard to create a sensor.
trigger on temp change. pseudo for the
value of sensor something like:
if trigger.to_state.state - trigger.from_state.state >0
If this.state == 'falling' or 'local_maxima'
'local_minima'
else
'rising'
else if trigger.to_state.state - trigger.from_state.state < 0
If this.state == 'rising' or 'local_minima'
'local_maxima'
else
'falling'
else
state.state
trigger on local_minima
Set up a trigger-based template binary sensor:
template:
- trigger:
- platform: state
entity_id: sensor.temp_sensor
binary_sensor:
- name: "Temperature rising"
state: "{{ trigger.to_state.state|float > trigger.from_state.state|float }}"
then your automation can trigger off a simple state change of that binary sensor from off
to on
. That’s similar to what you do with a Trend sensor, triggering off a change form negative to positive gradient.
That relies on your temperature sensor not going unavailable
or unknown
— put another “shield” template sensor in front of it if that is a risk.
The new template binary sensor will be unknown
until the source temperature sensor sends its first new (different from previous) reading.
You can also use a derivative sensor to get the rate of change of the temperature.
if the temp is decreasing the derivative is negative. If increasing the derivative is positive. you could use the state of the derivative in comparison to 0 to trigger an automation.
trigger:
- platform: numeric_state
entity_id: sensor.your_sensor
above: 0
be aware that the derivative sensor is slightly faulty in the way it works since it will never have a value of 0. There’s an open issue and AFAIK it hasn’t been fixed. (not that you asked about a flat temperature trend but just wanted to throw it out there just in case)