Automation fails when condition is not correct

Trying to automate my A/C to turn on if it colder than 17°C after 5:30am, but the automation fails if the temp falls below 17°C before 5:30am.
Is there a better way to do this.

alias: Cold Night Auto on
description: “”
trigger:

  • platform: numeric_state
    entity_id: sensor.actron_temperature
    for:
    hours: 0
    minutes: 0
    seconds: 10
    above: 0
    below: 17
    condition:
  • condition: and
    conditions:
    • condition: time
      after: “05:30:00”
      before: “09:00:00”
      action:
  • data:
    hvac_mode: heat
    temperature: 18
    service: climate.set_temperature
    target:
    entity_id: climate.air_conditioner

As I can see it failed due to the time being 3:47 am and not after 05:30.
Format your attached code with </> otherwise it is difficult to see if you have any faults in that.

Hi, it’s difficult to diagnose problem when your code is not formatted correctly as indentations are crucial, see the following:

Having said that it looks like your action might be under the condition which is certainly not correct.

alias: Cold Night Auto on
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.actron_temperature
    for:
      hours: 0
      minutes: 0
      seconds: 10
    above: 0
    below: 17
condition:
  - condition: and
    conditions:
      - condition: time
        after: "05:30:00"
        before: "09:00:00"
action:
  - data:
      hvac_mode: heat
      temperature: 18
    service: climate.set_temperature
    target:
      entity_id: climate.air_conditioner
  - data:
      fan_mode: low
    entity_id: climate.air_conditioner
    service: climate.set_fan_mode
  - type: turn_off
    device_id: da06b117bae04f0c87791a74c83ec3d5
    entity_id: switch.master_bedroom_zone
    domain: switch
  - type: turn_off
    device_id: da06b117bae04f0c87791a74c83ec3d5
    entity_id: switch.annas_zone
    domain: switch
  - type: turn_off
    device_id: da06b117bae04f0c87791a74c83ec3d5
    entity_id: switch.brodys_zone
    domain: switch
  - type: turn_off
    device_id: da06b117bae04f0c87791a74c83ec3d5
    entity_id: switch.maxs_zone
    domain: switch
mode: restart

Dam thought i had the right indents Thank you!

condition:
  - condition: time
    after: "00:05:30"
    before: "09:00:00"

To clean up since your not using the ”and”

I think the conditions looks OK so that makes be think about the trigger before it. Try removing the above: 0 and see if that works. I checked all my similar automations and they just use either above or below so it might be worth a try.

Hi @Mats789
ok thanks ill try that!

@Jonah1970
Thanks Mark
I’ll try that thank you Gents

As Mark noted, the condition should work anyways but you didn’t use the ”and” for anything so I removed it. As I said in my first answer, make sure the condition is met.
The trigger seems ok, and is also triggered according to the trace but the condition is not met.

Edit: As said below the automation will not trigger again if temp goes below 17 before 05:30 and stays below. I would change according to the suggestions below.

You should actually have 2 triggers here (implicit OR)

  • 5:30
  • T° < 17

and 2 conditions:

  • t between 5:30 and 9:00
    AND
  • T° < 17

typically, an input_boolean of sort is also used in conditions to “soft disable” the automation in case of, e.g., manual override.

1 Like

The automation is logically flawed given what you want, but it works exactly as it should as per your description in the first post. What you need to do is to change from a numeric_state to a state trigger so that it triggers in all state changes. Then put the temperature as a condition with the time condition.

Also, do away with the device calls and use normal service calls.

EDIT: As @koying said (beat me to it). I missed the time trigger. You should add that too.

1 Like

Ok great thanks for all the feed back.