Unable to get time trigger to work

this is my first post here. I installed Hass.io a few days ago and am now trying to automate turning on and off a Sonoff s26 which I have flashed with Tasmota. I am able to manually switch it on and off through a switch on the home screen, and I have created two time triggered automations that successfully turn on and off the switch when I trigger them manually. But when I set a time, they don’t trigger automatically.

I did use the automation editor in configuration when creating the automations, and have also tried to update them manually with no success.

This is my automations.yaml file:

- id: '1549655703172'
  alias: Turn on switch
  - at: '16:04:05'
    platform: time
  condition: []
  - data:
      payload: 'on'
      topic: cmnd/sonoff/power
    service: mqtt.publish
- id: '1549717446552'
  alias: Turn off switch
  - at: '14:54:35'
    platform: time
  condition: []
  - data:
      payload: 'off'
      topic: cmnd/sonoff/power
    service: mqtt.publish

The sonoff switch is configured in configuration.yaml

  broker: core-mosquitto
  username: admin
  password: HAdtarGIaNSALtenu
    platform: mqtt
    name: "Sonoff Switch 01"
    command_topic: "cmnd/sonoff/power"
    state_topic: "stat/sonoff/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

Some more background info:
I did remember to reload automations after editing
I am able to turn on and off the lights by calling the mqtt.publish service with the service data, so I’m pretty sure it’s my automation not getting triggered rather than the action not working.

 "topic": "cmnd/sonoff/power",
  "payload": "on"

Full configuration.yaml:

Any help is greatly appreciated!

Rather than publishing mqtt messages to turn your device on and off you can just call the switch services.

    service: switch.turn_on
    entity_id: switch.your_switch_id_here # probably switch.sonoff_switch_01 but check (see below)

Other services are switch.turn_off and switch.toggle.

To find the entity_id of your switch look in developer tools states menu (lower left side menu icon, looks like this <> )

Your time triggers look ok so if this does not work check your system time (timezone) is set correctly.

1 Like

If the automations work when manually triggered, but they don’t trigger at the times specified, then it could be the automations are turned off. Make sure they are on.

If that’s not it, then @tom_l may be correct and your system clock, or the time zone settings (in HA and in the environment in which HA runs) are not set correctly.

To help figure this out, try entering the following in the Template Editor:

{{ utcnow() }}
{{ now() }}
{{ utcnow().astimezone() }}
{{ now().astimezone() }}
{{ utcnow().tzinfo }}
{{ now().tzinfo }}
{{ now().astimezone().tzinfo }}

If you need help interpreting the output, post it here, and let us know what time zone you are in.

@ pnbruckner Thanks for the input. I previously checked the time by putting it on the overview screen, but this was a better way. The time shown is correct:
2019-02-10 07:17:22.956582+00:00
2019-02-10 08:17:22.956708+01:00
2019-02-10 08:17:22.956863+01:00
2019-02-10 08:17:22.965119+01:00

@tom_i I tried that first, but since the automations didn’t work I suspected at first that it was the action that failed. Since I managed to verify the mqtt method I left it at that. Will definately go back to calling the switch service once the trigger works.

@tom_l Oh, wow. Now I got it. The switches on the automations turn them on or off! I thought they reported back the state of the button after executing. It’s working fine now. Thanks for the help!