Automation not triggering at specific times

Hi people.

I’ve been fighting with my automation for a while now, maybe someone can shine a bit light on what I’m doing wrong. Basically I just want a very simple automation to turn my den lights on and off at specific times. On the forum, I found the following code (modified slightly for me)

automation:
- alias: "Lights Out"
  trigger:
    platform: time
    at: '23:30:00'
  action:
    - service: homeassistant.turn_off
      data:
        entity_id: light.a3

I have confirmed if I manually trigger the event, the light will turn off. However, regardless what time I set it to, it’ll never automatically trigger. I have confirmed the timezone is correct and the server’s time shows fine (using a time sensor). What else am I missing?

The basics … make sure the timezone setting in both HA and the underlying OS agree and are correct. If you automatically launch HA via systemd, make sure that configuration doesn’t run HA with a different timezone. Of course, make sure the clock is also set correctly. Lastly, make sure the automation is actually turned on.

Oh man…major derp on my behalf… I don’t know what I was thinking the “ON” switch meant but yeah, that was the issue!

Another issue I’m having right now though is getting two devices to turn off.

  - alias: LightsOff
    trigger:
      - platform: time
        at: '23:00:00'
    action:
    - service: light.turn_off
      data:
        entity_id:
          - light.den
          - light.a3

Only “light.den” will turn off…

Don’t see anything wrong with that. Any clues in the logs?

2019-01-15 22:47:26 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on (c:8348f723ca3b445484daa1d60f081e0a): entity_id=['light.den']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1177, in _event_to_service_call
    await service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/__init__.py", line 355, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/hue.py", line 355, in async_turn_on
    await self.light.set_state(**command)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohue/lights.py", line 75, in set_state
    json=data)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohue/bridge.py", line 64, in request
    data = await res.json()
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 947, in json
    return loads(stripped.decode(encoding))
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 79 (char 78)
2019-01-15 22:47:52 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 224, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/hue.py", line 378, in async_turn_off
    await self.light.set_state(**command)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohue/lights.py", line 75, in set_state
    json=data)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohue/bridge.py", line 64, in request
    data = await res.json()
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 947, in json
    return loads(stripped.decode(encoding))
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 79 (char 78)

Restarted HA and triggered the event. Nothing specifically points to it. I can manually turn on the lights through HA.

I don’t know anything about hue bridges, etc., but that looks like some kind of communications problem. Maybe it can’t accept two light commands that close together or something. Maybe try:

  - alias: LightsOff
    trigger:
      - platform: time
        at: '23:00:00'
    action:
      - service: light.turn_off
        entity_id: light.den
      - delay: 1
      - service: light.turn_off
        entity_id: light.a3

I’ll try this when I get home. I guess I should have specified my Hue bridge actually connects to a little Rasberry Pi running a bridge to allow X10 devices to emulate as Hue devices.