Simple Automations Don't Work

I have seen a bunch of similar posts in my research trying to figure out what the problem with my HA install is, but so far none have been able to solve this issue for me. The issue is that none of my automations run, or don’t run reliably, ever. Initially, I set up an automation that was supposed to run a scene at sunset. If I manually triggered it, it would run, but never on its own. I messed with my longitude and latitude in the config file, I triple-checked my location/timezone, couldn’t figure it out. So I decided to make an automation that just triggered that scene at 6 pm every night. Even more simple. But it wouldn’t work either. Again, I could manually trigger it, but at that time each day, nada. What’s even weirder is that sometimes that automation would run at the strangest times. More than once I was awoken in the middle of the night by all my lights turning on. Sometimes it would happen at like 10 am, but never two days in a row/every day.

So after talking with some people on Reddit and the HA Discord server I decided that maybe it was my installation that was the problem. You see, until last week I was running HA via a VM on my old MacBook Pro. The thing is from 2009 and was somehow still running on the original HDD, so I figured I would update it a bit and install Linux right on the machine so I wouldn’t have to bother with the VM. I bought a new SSD and memory to upgrade my RAM from 4GB to 8GB (why not?). I read the community guide on Installing Home Assistant Supervised on Debian 10 so I figured that was the distro to use since it would give me a supported installation of Home Assistant Supervised. I made a Debian disk image and installed it on the new SSD. Now the Macbook is only running that OS.

I then followed the guide above to install Home Assistant and restored my system from a snapshot I had taken. Everything works beautifully, it’s faster than it was before and I really thought my issue might be solved. I made an automation that would turn off my desk light at 10 am and sat here at my desk working away, waiting for 10 am to come. Well… it’s come and gone and the light never turned off. I want to move on to more complex parts of Home Assistant like turning lights off in rooms that haven’t been occupied for x minutes/hours or checking temp from a sensor in one room and sending an MQTT message to my Sonoff RF bridge to turn on the in-window air conditioner. I just don’t think I will have success if I can’t get the most basic automations to run. Can anyone think of something I can try to get things rolling?

Thanks!

As I’m pretty new myself in the HA business I’ve been to some try & error by myself. I don’t have any clue what little thing could be wrong but I have to ideas for you:

  1. Just post your code for one of those simple automations and we can check if we find something unusal.
  2. You said that you restored you’re maybe faulty configuration fram a snapshot. Have you tried to put up a fresh installation with maybe just a few integrations to check if that helps in the first part?
1 Like

Without any warranty but Ockhams razor I would suspect your code if the error continues to occur on a new system.

1 Like

As suggested above you need to post your current code for one of those automations that aren’t working.

It’s impossible for anyone to suggest a fix if we don’t see the actual code you are using.

make sure you properly format your code blocks by putting three backticks (```) on the line before and after the code.

1 Like

Of course, you gotta see the code.

here is the 10 am automation, the only one I have in my automation file

- id: '1620708684843'
  alias: Tes123
  description:
  trigger:
  - platform: time
    at: '10:00'
  condition: []
  action:
  - type: turn_off
    device_id: 42b4c4ee3ed8331b75deb96cdab9d49e
    entity_id: light.fungus_light
    domain: light
  mode: single

here is my config file

# Home Location Data/Preferences
homeassistant:
  name: Redondo
  latitude: XX.726490
  longitude: -XXX.878040
  elevation: 1302
  unit_system: imperial
  temperature_unit: F
  time_zone: "America/Denver"

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Lutron Config
lutron_caseta:
  host: 192.168.86.42
  keyfile: /ssl/lutron/caseta.key
  certfile: /ssl/lutron/caseta.crt
  ca_certs: /ssl/lutron/caseta-bridge.crt
  

Here is my groups file -

nightstand_lights:
        name: Nightstand Lights
        entities:
            - light.andrews_side
            - light.saras_side
tv_lamps:
        name: TV Lamps
        entities:
            - light.livingroomleft
            - light.livingroomright
stairway_light:
        name: Stairway Lights
        entities:
            - light.stairway_one
            - light.stairway_two

Want to look at anything else?

I don’t see anything wrong with this code (although I don’t use device automations). Did you reload your automations after changing it ?

Else, try

- id: '1620708684843'
  alias: Tes123
  description:
  trigger:
  - platform: time
    at: 10:00
  condition: []
  action:
  - type: turn_off
    device_id: 42b4c4ee3ed8331b75deb96cdab9d49e
    entity_id: light.fungus_light
    domain: light
  mode: single


1 Like

I created this automation on the front end (Configuration > Automations > Add Automation) and built it with the visual editor. I did not reload the automation file, but I will try that. Gonna change it to noon to see if it runs. File Editor won’t let me save the file without the ’ ’ around the time.

Any relevant messages in Configuration > Logs?

If you go to configuration->automations and then you should see your automation listted there.

on the right side you will see three icons - the one you want is the middle one (a circle clock). click on it.

you will then see a trace that should tell you the reasons that it isn’t running.

The only thing there is when I manually triggered the automation. I have updated it to run at 12 pm so I will post back afterward with the log so you can see.

Here is a copy of my log with every entry since I initiallized HA yesterday night -

2021-05-10 22:42:22 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly
2021-05-10 22:42:22 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=10 from 2021-05-06 16:16:39.180510)
2021-05-10 22:42:24 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from supervisor (172.30.32.2). (Python/3.8 aiohttp/3.7.4.post0)
2021-05-10 22:42:28 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from a_arredondo.lan (192.168.86.39). (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36)
2021-05-10 22:42:28 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from a_arredondo.lan (192.168.86.39). (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36)
2021-05-10 22:42:30 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect to MQTT server due to exception: [Errno 113] Host is unreachable
2021-05-10 22:42:39 WARNING (MainThread) [homeassistant.helpers.entity] Update of camera.front_door is taking over 10 seconds
2021-05-10 22:42:39 WARNING (MainThread) [homeassistant.components.ring.camera] Time out fetching recording url for camera camera.front_door
2021-05-10 22:45:29 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring active dings data: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-10 22:47:29 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring active dings data: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-10 22:48:29 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring active dings data: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-10 22:49:39 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from debian.lan (192.168.86.103). (Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0)
2021-05-11 08:00:46 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring active dings data: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
2021-05-11 08:00:46 ERROR (MainThread) [homeassistant.components.hue.light] Timeout fetching light data
2021-05-11 08:00:46 ERROR (MainThread) [homeassistant.components.hue.sensor_base] Timeout fetching sensor data
2021-05-11 08:00:46 ERROR (MainThread) [homeassistant.components.hue.light] Timeout fetching group data
2021-05-11 08:00:50 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring device data: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
2021-05-11 08:00:54 WARNING (MainThread) [pylutron_caseta.smartbridge] ping was not answered. closing connection.
2021-05-11 08:16:28 WARNING (MainThread) [pylutron_caseta.smartbridge] Reconnecting...
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pylutron_caseta/smartbridge.py", line 434, in _monitor_once
await self._leap.run()
File "/usr/local/lib/python3.8/site-packages/pylutron_caseta/leap.py", line 78, in run
received = await self._reader.readline()
File "/usr/local/lib/python3.8/asyncio/streams.py", line 540, in readline
line = await self.readuntil(sep)
File "/usr/local/lib/python3.8/asyncio/streams.py", line 632, in readuntil
await self._wait_for_data('readuntil')
File "/usr/local/lib/python3.8/asyncio/streams.py", line 517, in _wait_for_data
await self._waiter
File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 848, in _read_ready__data_received
data = self._sock.recv(self.max_size)
TimeoutError: [Errno 110] Operation timed out
2021-05-11 10:38:50 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring device data: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-11 10:39:50 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring device data: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-11 10:40:50 WARNING (SyncWorker_1) [homeassistant.components.ring] Error fetching Ring history data for device 50338be9fcd9: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-11 10:41:50 WARNING (SyncWorker_0) [homeassistant.components.ring] Error fetching Ring history data for device 50338be9fcd9: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-11 10:44:50 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring active dings data: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-05-11 10:46:50 WARNING (MainThread) [homeassistant.components.ring] Error fetching Ring active dings data: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

It ran! Maybe it was a fluke that it didn’t work before. But thanks for encouraging me to stick with it!

That’s a boatload of complaints in that log. Wonky automations are just the tip of the iceberg.

Any idea why it has so many problems? I literally installed it step by step from the linked guide 24 hours ago.

It seems like you have network issues. The guide you posted has nothing to do with network issues, that’s just an installation guide. If you take the time to read the errors posted in your logs, they are all timeout/connection issues. You should investigate why these devices are timing out/losing connection.

Is your time set correctly? Go into developer tools and type in the following template

{{ now() }} 

You should get a result with your correct local time and timezone. Mine right now is

2021-05-12 20:02:00.002515+12:00

12th May 2021 and it is 8.02 pm, and I live in NZ which is 12 hours ahead of Greenwich.

I guess I meant that it’s a new install, so not a lot of time for things to have gotten mucked up by me messing around with stuff. But I see your point. Looking at the timeouts it seems like my Ring doorbell is most often the culprit. Funny enough it seems to work fine from the UI.

Hi, yes, my time seems to be set correctly. When I run that in the template I get

2021-05-12 09:23:39.752359-06:00

Which is the time in Utah right now.

My time-based automation ran okay yesterday so I decided to try a sun-based one again. It worked, but about an hour and a half after sunset. Do you know if HA has a way of accounting for daylight savings time?

Your time zone and elevation should handle that. Is your elevation correct or is it zero?

It is set, but I am not sure if it should be metric or standard. Right now it is in meters, but I will put it in as feet and see if that fixes it.