Switch automation at certain time troubles

I am attempting to change a switch state to on at a certain time.

automation:
  - alias: "Lights On"
    trigger:
      - platform: time
        at: '16:15:00'
    action:
      - service: switch.turn_on
        data:
          entity_id:
            - switch.wphome17l
          state: 'on'

Doesn’t seem to do anything at all. Is there anything that I’m not getting right here? I feel like it’s something to do with the service it’s calling but I’ve not found anything to say otherwise

I had this simple automation:

- alias: Pond pumps on
  trigger:
    - platform: time
      at: '11:00:00'
  action:
    service: switch.turn_on
    entity_id: switch.pond_pumps

But it did not start. It started to work when I added the following sensor and restarted:

- platform: time_date
  display_options:
    - time
    - date

I would have thought this dependency would be automatically resolved but it is working now anyway

I think your issue is the switch.turn_on service does not accept a state variable. You should write your automation this way:

automation:
  - alias: "Lights On"
    trigger:
      - platform: time
        at: '16:15:00'
    action:
      - service: switch.turn_on
        entity_id: switch.wphome17l

Thanks! I have changed the schedule for 10 minutes time so I will let you know what it does!

The Homekit device discovery does seem to be a bit iffy after a restart of HA though and I find I am having to restart the service multiple times to get the switch to appear again

OK, so it didn’t call the automation so I am just trying to include @reef-actor’s sensor for time

Honestly, I don’t see how enabling the date & time sensors has anything to do with this.

If an automation is not triggering when a time trigger using at: specifies, then it’s more likely you have a timezone issue. You should make sure that both HA and the underlying OS are set to the same, correct timezone. If they differ, that can cause time-based triggers to not work correctly. Setting both timezones correctly is a documented requirement.

Also, make sure your automation is ‘on’. I don’t know what your HA experience is, but I know some new users have gotten confused about what turning an automation on and off does.

I am an extremely new user to HA. Only started looking at it this week.

The timezone set within HA;

  time_zone: Europe/London

OS time;

root@V-Ubnt006:~# date
Thu Sep 13 17:04:58 BST 2018

I guess it’s possible there is a conflict if Europe/London is infact UTC and not BST. I am also not able to see whether it’s possible to set a +1 in HA. To test, I’ve set the time to be 18:30 BST, so if it is an hour out, by setting the time in the configuration to be 17:30, it will trigger.

Edit: it’s just gone 17:30 BST, so nothing yet so I will wait till 18:30BST and see if it works

Regarding setting the automation to on. How can I double check this? I can see the trigger within the main web UI and I can also trigger it using the automation.trigger in the Services page.

Light just came on. Thanks for your help guys! Just need to get it to send a push notification now :smiley:

Displaying and setting the timezone in Linux can get a bit complicated. But you should be able to check your OS’s timezone setting by doing this:

cat /etc/timezone

In your case, it should say Europe/London (if it agrees with the setting in HA.) Or you can use:

timedatectl

Which will show more info. E.g., for me it prints:

pi@raspberrypi:/home/homeassistant/.homeassistant $ timedatectl
      Local time: Thu 2018-09-13 12:47:56 CDT
  Universal time: Thu 2018-09-13 17:47:56 UTC
        RTC time: n/a
       Time zone: America/Chicago (CDT, -0500)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

And you can change it by doing:

sudo dpkg-reconfigure tzdata

See https://help.ubuntu.com/community/UbuntuTime for more details.

Thanks for that. I am a Linux sysadmin so that stuff is okay, it’s more the HA stuff that is new to me :slight_smile:

Okey dokey. Always hard to tell/guess at what ones background might be on this forum. :slight_smile: And it usually doesn’t hurt to spell things out anyway for others that might come along and find this discussion later who might not be as familiar with the details.