Simple timed automation with Google home switch doesn't work

Apologies if the answer is obvious, really noob to home assistant IO, literally just set it up a supervised homeassistant on my RPi 3 a week ago, although I have had quite a bit of experience dealing with RPi and Linux in general.

For the first warm up automation task I was planning to basically turn on a smart switch that connected to my bedroom heater at 10pm (if I am at home so that my home doesn’t burn into ashes if the heater catches fire!), and then as a second task turn it off after an hour later (i.e., at 11pm).

So for the turn on task, I set my trigger as the following:

platform: time
at: '22:00:00'

(I have also tried to set it to be after 22:00:00, also no luck.)

Trigger:

condition: state
entity_id: person.MY (and I have the Android app installed and I can see my status is Home in the Developer Tools -> Current Entities)
state: HOME

and finally actions:

type: turn_on
device_id: xxxxxxx
entity_id: switch.heater
domain: switch

My turn off automation is very similar except the Trigger is defined as following (and no conditions):

platform: device
type: turned_on
device_id: xxxxx
entity_id: switch.heater
domain: switch
for:
  hours: 1
  minutes: 0
  seconds: 0

But this Automation doesn’t seem to run at 10pm and if I turn it on manually, the turn off automation doesn’t execute either.

Here are a few things I have thought about to try to fix the issue.

  1. When I press the execute button (i.e., manually execute it), both automation tasks correctly turns the device on/off (even before 10pm), I assume this is because when I execute the timed portion of the task is ignored? However this seems to suggest the integration between Google home and home assistant is configured properly in my case and the action is configured properly.

  2. Checking using dpkg-reconfigure tzdata I can verify my timezone is set correctly to my home timezone. Also showing the correct timezone in my Configuration page

  3. There is no log book entry at 10pm, as if the tasks were never executed automatically.

Just wondering if I am thinking about this correctly or there is some stupid noob mistake I am making here. Also is there a log file that I can check in the supervised HA to see if there is any thing preventing this to run?

Here is my configuration page for reference:

System Health

version 2020.12.1
installation_type Home Assistant Supervised
dev false
hassio true
docker true
virtualenv false
python_version 3.8.6
os_name Linux
os_version 5.4.79-v7+
arch armv7l
timezone xxxxxxxx
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Hass.io
host_os Raspbian GNU/Linux 10 (buster)
update_channel stable
supervisor_version 2020.12.7
docker_version 20.10.1
disk_total 58.1 GB
disk_used 14.5 GB
healthy true
supported failed to load: Unsupported
supervisor_api ok
version_api ok
installed_addons Ring Devices (4.2.1)
Lovelace
dashboards 1
mode auto-gen
resources 0

Thanks in advance for your help!

Post the automation in its entirety as opposed to bits and pieces.

BTW, I doubt the value HOME (all caps) is valid for a person entity. Check the spelling of the entity’s state in Developer Tools > States (typically it’s lowercase home).

1 Like

Wow I think you might be right! I double-checked and it was Home rather than HOME, let me fix this one first and I’ll give it another shot, hopefully it will work this time!

Can’t believe I’d be committing to such a silly noob mistake, thanks once again for your super-fast reply!

Check Developer Tools -> States - you’ll likely find it’s really home and not_home :wink:

1 Like

Thank you guys, this is really helpful! Really appreciate all your super-fast responses. It is actually “Home” for some reason, I’ve fixed it as per @123 's suggestion and turn on seems to work! I am patiently awaiting to see if turn off would work as well (turn off doesn’t depends on if I am “Home” or not so it might be something else I am missing)…

Turn on worked but turn off didn’t seem to have any luck (I tried to set the turn off for 10 minutes after turning on for testing). Here is my entire turn off task in automations.yaml (the original setting with turning off an hour after turning on), do you mind take a quick peek to see if I am making another stupid noob mistake somewhere? Thanks in advance!

- id: '1608501339492'
  alias: Turn off heater after an hour if heater is on
  description: ''
  trigger:
  - platform: device
    type: turned_on
    device_id: xxxxx
    entity_id: switch.heater
    domain: switch
    for:
      hours: 1
      minutes: 0
      seconds: 0
  condition: []
  action:
  - type: turn_off
    device_id: xxxxx
    entity_id: switch.heater
    domain: switch
  mode: single

Seems fine. Try this abbreviated version instead.

- id: 'abc123xyz789'
  alias: Heater off after umpteen minutes
  trigger:
  - platform: state
    entity_id: switch.heater
    to: 'on'
    for: '00:10:00'
  action:
  - service: switch.turn_off
    entity_id: switch.heater

Remember, it counts down the for: period (10 minutes in the example I posted) from the moment the switch changes from some other state to on. Afterwards, the switch must remain in the on state for 10 continuous minutes before it is shut off.

1 Like