Specific time and day set up?

i test it as i add one more time interval from 5-5:30 pm, but the automation did not start so that is why i run it manually to see what will happen. Now i tried to make it with IF-Else statement but again it is not working and in the Logbook i did not see the schedule to be triggered. Very strange …

alias: Water heater turns on when someone is in Sofia
description: ""
trigger:
  - platform: state
    entity_id:
      - schedule.water_heater_schedule
condition:
  - condition: numeric_state
    entity_id: zone.in_sofia
    above: 0
action:
  - if:
      - condition: state
        entity_id: schedule.water_heater_schedule
        state: "on"
    then:
      - type: turn_on
        device_id: 503857c51fe1e6affa87f28476dcc045
        entity_id: switch.water_heater_switch_1
        domain: switch
    else:
      - type: turn_off
        device_id: 503857c51fe1e6affa87f28476dcc045
        entity_id: switch.water_heater_switch_1
        domain: switch
mode: single
  1. Go to Developer Tools > States
  2. Find schedule.water_heater_schedule and click on it
  3. Scroll up to the top of the page and you will see something like this:
  4. In the State field, change it from off to on
  5. Click the Set State button.

That should be sufficient to trigger your automation and the automation Tinkerer suggested (with the correction).

If you come home after the schedule turns on then the automation won’t fire. The following handles that:

alias: Water heater turns on when someone is in Sofia
description: ""
trigger:
  - platform: state
    entity_id: schedule.water_heater_schedule
    to:
  - platform: numeric_state
    entity_id: zone.in_sofia
    above: 0
condition:
  - condition: numeric_state
    entity_id: zone.in_sofia
    above: 0
action:
  - if:
      - condition: state
        entity_id: schedule.water_heater_schedule
        state: "on"
    then:
      - type: turn_on
        device_id: 503857c51fe1e6affa87f28476dcc045
        entity_id: switch.water_heater_switch_1
        domain: switch
    else:
      - type: turn_off
        device_id: 503857c51fe1e6affa87f28476dcc045
        entity_id: switch.water_heater_switch_1
        domain: switch
mode: single

Will handle that - though you still don’t have the case handled of what happens if you leave the zone. It’s quite possible for this automation to leave the heat on.

I’ve tried that automation which is working for now ( turns on the water heater in the specified time) and i will see if it will turned off in 6:30 pm. I make some changes in the conditions so no matter if we are at home zome or in sofia zone the automation will run.

alias: Water heater turns on when someone is in Sofia
description: ""
trigger:
  - platform: state
    entity_id:
      - schedule.water_heater_schedule
condition:
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: zone.home
        above: 0
      - condition: numeric_state
        entity_id: zone.in_sofia
        above: 0
action:
  - if:
      - condition: state
        entity_id: schedule.water_heater_schedule
        state: "on"
    then:
      - type: turn_on
        device_id: 503857c51fe1e6affa87f28476dcc045
        entity_id: switch.water_heater_switch_1
        domain: switch
    else:
      - type: turn_off
        device_id: 503857c51fe1e6affa87f28476dcc045
        entity_id: switch.water_heater_switch_1
        domain: switch
mode: single

After that test i will try again Tinkerer code with Taras suggestions, something like that

alias: Water heater turns on when someone is in Sofia
description: ""
trigger:
  - platform: state
    entity_id:
      - schedule.water_heater_schedule
condition:
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: zone.home
        above: 0
      - condition: numeric_state
        entity_id: zone.in_sofia
        above: 0
action:
  - service: - service: "switch.turn_{{ trigger.to_state.state }}"
    target:
      entity_id: switch.water_heater_switch_1
mode: single
1 Like

I believe that could work if you just remove the duplicated - service:

it is typo :smiley: thanks
For now the code that i tried with IF and Else is working.
i will try the one with typo later to see if it is working :slight_smile:

thank you all guys, both of the variants works fine now :wink:

Hello, how can I make this automation to wait specific time before triggering again. Now it is happening to turn on twice in 30 min or hour, because temp is below the desired temp.

You can add a delay as the last action, which when the automation is in single mode (the default), will stop further runs from happening for that time.

Like that ?

description: ""
trigger:
  - platform: state
    entity_id:
      - schedule.valeri_airconditioner
    to: "on"
  - platform: numeric_state
    entity_id:
      - sensor.rm4_mini_temperature
    below: 20
  - platform: numeric_state
    entity_id:
      - zone.home
      - zone.in_sofia
    above: 0
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: schedule.valeri_airconditioner
        state: "on"
      - condition: numeric_state
        entity_id:
          - sensor.rm4_mini_temperature
        below: 20
      - condition: or
        conditions:
          - condition: numeric_state
            entity_id: zone.home
            above: 0
          - condition: numeric_state
            entity_id: zone.in_sofia
            above: 0
action:
  - service: scene.turn_on
    target:
      entity_id: scene.valeri_air_conditioner
    metadata: {}
  - device_id: 5a324c34182495672c52d180876f56b4
    domain: mobile_app
    type: notify
    message: Valeri's air conditioner is turned on
  - delay:
      hours: 1
      minutes: 0
      seconds: 0
      milliseconds: 0
mode: single

Exactly like that