Automation condition woes

Hi all, this automation works without the condition but not with it. I’m new to HA, but I’m a developer… so pretty good with code usually, after reading the docs and looking at examples, I don’t see why this doesn’t work. But I’m using YAML for the first time.

alias: TV Time
condition:
  - condition: time
    after: '20:00:00'
    before: '23:59:59'
trigger:
  - platform: state
    entity_id: group.office
    to: 'off'
action:
    service: switch.turn_on
    entity_id: switch.wemo_switch

have you looked at Node Red and using the big timer node to do you automation?

This is how I have mine I think you need to reduce the time to this format in a condition ‘20:00’ and '23:59"

  - alias: 'Good Morning'
    trigger:
    - platform: state
      entity_id: binary_sensor.motion_sensor_158d00022c2f21
      to: 'on'
    condition:
    - condition: state
      entity_id: input_boolean.morning_script_run
      state: 'on'
    - condition: time
      after: '04:00'
      before: '09:00'  
    action:
    - service: tts.google_say
      data:
        entity_id: media_player.tts_kodi
        message: Good Morning Team
    - service: script.1527974742281
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.morning_script_run
1 Like

Could you maybe try putting the trigger: section before the condition: section because YAML can sometimes be really picky with the way the codes are laid out.

1 Like
condition:
  - condition: time
    after: '20:00'

you don’t actually the before 23:59 as this will obviously be true if the time is after 20:00 (after 23:59:59, time goes to 00:00:00 which is less than 20:00)
Alternatively you could use a template:

condition:
  - condition: template
      value_template: '{{now().hour>20}}'
1 Like