Different action based on conditions

Hello everyone,
I now have an automation that checks every hour two parameters: humidity and temperature.
If the temperature is <25°C and humidity>60% a fan connected to a smart switch starts, else not.
What I would like to do is add another condition so that every hour it checks, if temp<25 & hum>60 OR if hum>75 it starts.
How could i do it?

This is my actual setup:

#Controllo Umidità ogni 60 minuti
- id: Controllo_Umidita
  alias: Controllo Ventola Ogni 60 Minuti
  description: 'Condizioni: umidità>60% && Temp<25'
  trigger:
  - hours: '/1'
    platform: time_pattern
  condition:
  - above: '60'
    condition: numeric_state
    entity_id: sensor.umidita_balconcino
    #value_template: "{{states('sensor.umidita_balconcino')}}"
  - below: '25'
    condition: numeric_state
    entity_id: sensor.temperatura_balconcino
    #value_template: "{{states('sensor.temperatura_balconcino')}}"
  action:
  - service: notify.christian
    data_template:
      title: '*Balconcino*'
      message: Ventola attivata, temperatura {{states('sensor.temperatura_balconcino')}}°C,
        umidità {{states('sensor.umidita_balconcino')}}%
  - device_id: f4fbd3f3debf4c9f9c36db094121d525
    domain: switch
    entity_id: switch.06673331bcddc294d6ec
    type: turn_on
  - delay: '0:10:00'
  - device_id: f4fbd3f3debf4c9f9c36db094121d525
    domain: switch
    entity_id: switch.06673331bcddc294d6ec
    type: turn_off
  mode: single
  

I would choose another approach. instead of checking every hour, make it trigger whenever the desired events occur.

#Controllo Umidità
- id: Controllo_Umidita
  alias: Controllo Ventola
  description: 'Condizioni: umidità>60% && Temp<25'
  trigger:
  - platform: template
    value_template: >
      {{ states('sensor.umidita_balconcino')|int > 60 and
         states('sensor.temperatura_balconcino')|int < 25 }}
  - platform: template
    value_template: >
      {{ states('sensor.umidita_balconcino')|int > 75 }}
  action:
  - service: notify.christian
    data_template:
      title: '*Balconcino*'
      message: Ventola attivata, temperatura {{states('sensor.temperatura_balconcino')}}°C,
        umidità {{states('sensor.umidita_balconcino')}}%
  - device_id: f4fbd3f3debf4c9f9c36db094121d525
    domain: switch
    entity_id: switch.06673331bcddc294d6ec
    type: turn_on
  - delay: '0:10:00'
  - device_id: f4fbd3f3debf4c9f9c36db094121d525
    domain: switch
    entity_id: switch.06673331bcddc294d6ec
    type: turn_off
  mode: single

However, I should point out that this will work differently compared to your automation.

Your automation checks every hour. If the humidity is above 75, you are notified. If the humidity is still above 75 an hour later you get notified again (and yet again an hour later as long as the humidity exceeds 75). If this is the behavior you want then do not use the automation example I posted above.

That example will only notify you once, the first time the humidity exceeds 75. It won’t notify you again until the humidity falls below 75 first and then increases above 75.


If you want the original behavior (to be notified every hour if, for example, humidity remains above 75) then you must modify the condition of your original automation.

The condition in the following example is structured like this:

(Humidity > 75) OR (Humidity > 60 AND Temperature < 25)

#Controllo Umidità ogni 60 minuti
- id: Controllo_Umidita
  alias: Controllo Ventola Ogni 60 Minuti
  description: 'Condizioni: umidità>60% && Temp<25'
  trigger:
  - hours: '/1'
    platform: time_pattern
  condition:
    condition: or
    conditions:
    - condition: numeric_state
      entity_id: sensor.umidita_balconcino
      above: 75
    - condition: and
      conditions:
      - condition: numeric_state
        entity_id: sensor.umidita_balconcino
        above: 60
      - condition: numeric_state
        entity_id: sensor.temperatura_balconcino
        below: 25
  action:
  - service: notify.christian
    data_template:
      title: '*Balconcino*'
      message: Ventola attivata, temperatura {{states('sensor.temperatura_balconcino')}}°C,
        umidità {{states('sensor.umidita_balconcino')}}%
  - device_id: f4fbd3f3debf4c9f9c36db094121d525
    domain: switch
    entity_id: switch.06673331bcddc294d6ec
    type: turn_on
  - delay: '0:10:00'
  - device_id: f4fbd3f3debf4c9f9c36db094121d525
    domain: switch
    entity_id: switch.06673331bcddc294d6ec
    type: turn_off
  mode: single
1 Like

PERFECT!
The second code you wrote was exactly was i was looking for, thank you very much

1 Like

You’re welcome!

For the benefit of other users, please consider marking my previous post with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. It will also automatically place a link below your first post that leads to the solution post. All of this helps other users who may have the same question.

1 Like