Temperature trigger - Multiple values

Hi,

I’m looking the right way to trigger an automation when the temperature is going up.

My need :
I want to close the blinds when temperature in the house is above 24°C and is increasing.

My first solution :

trigger:
  platform: numeric_state
  entity_id: climate.etage_2
  value_template: '{{ states.climate.etage_2.attributes.current_temperature }}'
  above: 24

When temperature exceeds 24°C, the automation is triggered.
But, if the starting temperature is above 24°C, the temperature can rise without limit and never trigger the automation.

I’m looking for…
The right way to catch temperature rising, independently of the starting temperature.

I’ve think to multiply triggers with 24°C, 24.5°C, 25°C, 25.5°C, etc. But I don’t find it very clean.

Does anyone have any idea ?

Mike

Remove the above from the trigger. The trigger should always go off for every state change.

Then you can add a condition that checks if trigger.state.to_state is greater than trigger.state.from_state AND the to_state is above 24.

Hi @metbril

So I should have something like this :

trigger:
  platform: numeric_state
  entity_id: climate.etage_2
  value_template: '{{ states.climate.etage_2.attributes.current_temperature }}'
condition:
  condition: and
  conditions:
    - condition: template
      value_template: '{{ trigger.to_state.state > 24 }}'
    - condition: template
      value_template: '{{ trigger.from_state.state < trigger.to_state.state }}'

Is that right ?

That looks good. Just to let you know, you don’t need to specify and when dealing with conditions. It defaults to and:

trigger:
  platform: numeric_state
  entity_id: climate.etage_2
  value_template: '{{ states.climate.etage_2.attributes.current_temperature }}'
condition:
  - condition: template
    value_template: '{{ trigger.to_state.state > 24 }}'
  - condition: template
    value_template: '{{ trigger.from_state.state < trigger.to_state.state }}'

why would you want the automation to trigger on each temp change, and not only at above 24. Seems a waste of resources to have it triggering all the time?

having the automation triggered only at above 24 degrees, under the condition the temp is rising seems a rather adequate way of saving on the limited resources the Pi has?

had several of these triggers, that kept my Hassio instance busy like forever. Changed several of these into booleans (in this case {true for temp=24} and the system settled quite nicely. Use that as a trigger would be prudent?

1 Like

He’s specifically looking for changes above 24. I’m sure he could use a value template instead:

trigger:
  - platform: template
    value_template: '{{ states.climate.etage_2.attributes.current_temperature > 24 }}'
condition:
  - condition: template
    value_template: '{{ trigger.from_state.state < trigger.to_state.state }}'

EDIT: I think his original problem is that it only triggered when to moved from under 24 to above 24.

exactly, that, or a binary_sensor with that value_template :wink:

or have it use the trend_sensor:

38

@petro thanks !

@Mariusthvdb In my first automation I did it this way, only trigger when temperature going above 24.
But days are getting warmer and warmer at this time of year, and the temperature in my house is not decreasing below 24 every night.
So if in the morning the temperature is already above 24, my blinds will never get closed and my house can be a sauna at night!.

But I agree with you, triggering every temperature change could be a problem in two way:

  • waste of ressources
  • trigger on minor temperature change, which may not be due to the sun

Could you explain your boolean solution?
I’m new to HA, I still have a lot to learn!

Mike

To be complete, here is my entire automation:

  trigger:
    - platform: numeric_state
      entity_id: climate.sejour_2
      value_template: '{{ states.climate.sejour_2.attributes.current_temperature }}'
      above: 24
    - platform: numeric_state
      entity_id: climate.sejour
      value_template: '{{ states.climate.sejour_2.attributes.current_temperature }}'
      above: 25
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: sun.sun
        state: 'above_horizon'
      - condition: numeric_state
        entity_id: sensor.meteo_cloudiness
        below: 90
      - condition: numeric_state
        entity_id: sun.sun
        value_template: "{{ states.sun.sun.attributes.azimuth }}"
        below: 200
  action:
    service: cover.close_cover
    entity_id: group.down_east_covers

trend_sensor seem to be a good option.

The temp_rising exemple matches what I’ve in mind.
I’ll give it a try and come back with the result.

Hi,
It would be also a good option to create 2 different automations. As far as I understand you would like to control your covers only after sunrise and before sunset.
First automation is triggered by sunrise and the condition is checking the temperature.
The second automation is triggered by the high temperature and the condition should be the sun above the horizon.
BR:
P!

Hi good evening, I am new to HA world and programming automation in yaml…
I wrote this automation but it doesn’t work in my HA, there must be syntax errors in the yaml code:
I want to create an automation that when the temperature increases → send me an email: boiler works wellel

CODE YAML:

  • alias: Controller_Boiler_works_good
    trigger:
    • platform: numeric_state
      entity_id: sensor.sonoff_XXXXX_temperature
      #value_template: ‘{{ #states.sensor.sonoff_XXXXX_temperature.attributes.current_temperature }}’
      value_template: ‘{{ states(sensor.sonoff_XXXXX_temperature) }}’
      condition:
    • condition: template
      value_template: ‘{{ trigger.from_state.state < trigger.to_state.state }}’
    • platform: state
      entity_id: switch.sonoff_XXXXX
      from: ‘off’
      to: ‘on’
      action:
      • service: notify.mail
        data:
        message: OK Boiler works good
        title: OK Boiler works good