@Kfox (Kfox) posted a new topic, subject "Automation trigger and time not working". It read:

   I did yaml validator and restarted the configurator, but this script didn't work??  
    Do I need to add-on a time counter or something?
    
    automation:  
    trigger:  
    platform: time  
    at: “08:18:00”  
    action:  
    service: switch.turn_on  
    entity_id: switch.light_livingroom_couch  
    data:  
    #900 seconds = 15 minutes  
    transition: 90

Then @AhmadK (akasma74) said

    You need to post your config preserving its format - put 3 single backquotes around it.  
    From what I see your problem is in calling the service, it should be something like according to examples here:
    [code] 
        action:
          service: switch.turn_on
          data:
            entity_id: switch.light_livingroom_couch
            transition: 90
        
    [/code]

So @Kfox (Kfox) replied

    sorry, I did not post the correct format, but I do have the correct format in my yaml file and it still does not work?
    
    I did use an example from here.  
    
    
    Home Assistant
    
    ### Examples using the sun
    
    Automation examples that use the sun.
    [code] 
        automation:
          trigger:
            platform: time
            at: "07:15:00"
          action:
            service: light.turn_on
            entity_id: light.bedroom
            data:
              # 900 seconds = 15 minutes
              transition: 900
        
    [/code]

Then @AhmadK (akasma74) said

    I see.  
    Could you post **your** automation that doesn't work and also explain what that “does not work” means with as many relevant details as possible to help you further?

Then @Kfox (Kfox) said

    I just changed the code to the code below:  
    I entered the new time at 10:36 and did my configurator check and restarted HA just in case.  
    I entered the new time around 10:30 then waited until 10:36 and my light did Not turn on?  
    Screen shot is part of my yaml file.  
    
    [code] 
        automation:
          trigger:
            platform: time
            at: "10:36:00"
          action:
            service: homeassistant.turn_on
            entity_id: switch.light_livingroom_couch
    [/code]

@Kfox (Kfox) replied

    This is also in my yaml file  
    
    
    image339×505 7.28 KB
    
    and this works manually  
    
    
    and here are setting on this page  
    
    
    and this  
    
    
    image853×535 48.1 KB
    
    and…  
    
    
    image809×105 11 KB

Then @AhmadK (akasma74) said

    try adding
    [code] 
        initial_state: 'true'
        
    [/code]
    
    to your automation as per this doc

So @Kfox (Kfox) replied

    That was good advice but when my laptop turned 11:15, it did Not turn the switch on.
    [code] 
        automation:
          initial_state: 'true'
          trigger:
            platform: time
            at: "11:15:00"
          action:
            service: homeassistant.turn_on
            entity_id: switch.light_livingroom_couch
    [/code]

@AhmadK (akasma74) replied

    If you call `homeassistant.turn_on` from development tools with your entity, does that work?

To which @petro (Petro) replied

    You have an extra space in front of automation that needs to be removed.

Then @anon34565116 said

    I think you should be using `light.turn_on` instead of `homeassistant.turn_on`. The second command is for groups, not individual lights.

To which @petro (Petro) replied

    Well according to this entity_id it would be `switch.turn_on`, although `homeassistant.turn_on` should work unless that functionality was removed.

So @AhmadK (akasma74) replied

    I think it's universal.

To which @Kfox (Kfox) replied

    @AhmadK  
    I changed spacing but then I got this notification in UI configurator  
    
    
    image1157×432 22.9 KB
    
    Then when I move spacing back to original I get an “ok” in the upper right hand corner  
    
    
    image1003×402 31 KB

After which, @Kfox (Kfox) added

    @AhmadK  
    Yes, this works  
    
    
    image934×440 31.2 KB
    
    and this works  
    
    
    BUT this does not work??

After which, @Kfox (Kfox) added

    @petro  
    t's a switch though, shouldn't I use switch.light.turn_on?

@Kfox (Kfox) replied

    @anon34565116  
    @petro
    
    I just realized how does HA determine if its AM or PM. I have been doing this in the evening. Do I need to use UTC time?

So @AhmadK (akasma74) replied

    Kfox:
    
    > and this works
    
    could you elaborate?
    
    Kfox:
    
    > shouldn't I use switch.light.turn_on?
    
    that does not make sense. it should be `switch` OR `light`
    
    Kfox:
    
    > I just realized how does HA determine if its AM or PM. I have been doing this in the evening. Do I need to use UTC time?
    
    I think it's local time. What exactly did you realise? Can see no bearing with AM/PM and UTC…

After which, @petro (Petro) added

    You can't have 2 automation sections. That's your problem. You need to place your automation inside automations.yaml, which you specified in line 40.
    
    image736×266 31.4 KB
    
    So, your automation is never added to home assistant because of the extra space. Then when you remove the space, it's never added because you already have an automation section.
    
    Once you rectify that problem, the automation should work. I.E. Copy the automation into automations.yaml. Make sure you omit the word automation inside automations.yaml, otherwise you'll have more errors. You'll also need to add an - alias line when inside automations.yaml.

To which @Kfox (Kfox) replied

    @AhmadK  
    I realized that in my config.yaml, when I specified the time 11:15:00 that there is no AM/PM. How would HA know if it was AM or PM? Unless I am supposed to use UTC time 23:15:00?
    
    Correct, no bearing on AM/PM

@123 (Taras) replied

    Kfox:
    
    > Unless I am supposed to use UTC time 23:15:00?
    
    You're mixing up UTC with displaying time in 24-hour format.
    
    UTC is an abbreviation for Coordinated Universal Time (in French). It is the successor to Greenwich Mean Time. It represents ‘time zone zero'.
    
    `23:15:00` is simply time expressed using a 24-hour clock (45 minutes before midnight or 11:15 PM). Time expressed using a 24-hour clock doesn't imply it is UTC or EST or any other time zone unless it is explicitly indicated.
    
    Anyway, the principal reason the automation isn't triggering at the appointed time (Home Assistant uses a 24-hour clock so `10:36:00` means in the morning and in your _local time zone_ ) was explained by Petro. Your automation is defined in the wrong place and is ignored by Home Assistant.

Then @Kfox (Kfox) said

    @AhmadK
    
    I did see that post, I 'm going to try that.
    
    Thanks for the explanation

@Kfox (Kfox) replied

    @petro  
    @AhmadK  
    I got it  
    
    
    I will try in the 24 hour format and see what happens.

After which, @Kfox (Kfox) added

    @petro  
    @AhmadK  
    For some reason I am getting an error for something else?  
    Line 39 is referencing “group: !include groups.yaml”

Then @123 (Taras) said

    Look very carefully at the first example shown in the documentation. Pay close attention to how `alias` is defined.
    
    Home Assistant
    
    ### Automation Examples
    
    Some automation examples to get you started.
    
    HINT: Pay close attention to the indentation.

Then @Kfox (Kfox) said

    Got it!  
    Thanks

After which, @Kfox (Kfox) added

    @AhmadK  
    @petro  
    @123  
    My light turn on for the specified time!!! So cool!  
    Thanks for your help guys!!

To which @AhmadK (akasma74) replied

    You're welcome.  
    To sum it up, the problem was 2 automation sections and some wrong indentation, is that correct?

@Kfox (Kfox) replied

    @AhmadK  
    Yes, you were spot on with that!
    
    I'll definitely need to be more mindful of that, but the more I do it, it will become familiar.
    
    Thank you again


{'source': 'discourse', 'url': 'https://community.home-assistant.io/t/automation-trigger-and-time-not-working/112077', 'title': 'Automation trigger and time not working', 'views': 5074, 'has_accepted_answer': False, 'word_count': 1171, 'like_count': 3, 'reply_count': 25, 'participant_count': 5, 'posts': 29, 'tags': '', 'author': '@Kfox (Kfox)', 'participants': '@Kfox (Kfox), @AhmadK (akasma74), @petro (Petro), @anon34565116, @123 (Taras)', 'image_url': [None], 'created_at': '2019-04-19T03:22:22.879Z', 'last_posted_at': '2019-05-01T00:18:59.809Z'}