I just started with Home Assistant. I set up 2 test automations through the web interface. “Test flo” is triggered as expected. “Bett flo” is never triggered. Any ideas why?
I sure just can delete the non-working version. It is a bit strange and makes me uncertain about reliability of the program.
- id: '1573938386731'
alias: Bett flo
description: ''
trigger:
- at: '20:30'
platform: time
condition:
- condition: state
entity_id: device_tracker.samsung_galaxy_s7
state: home
action:
- device_id: bcb34f3c2c8547e4bc2e11b5dd8a6b34
domain: light
entity_id: light.tradfri_bulb_e27_ws_opal_980lm
type: turn_on
- id: '1574107740827'
alias: Test flo
description: ''
trigger:
- at: '21:10'
platform: time
condition:
- condition: state
entity_id: device_tracker.samsung_galaxy_s7
state: home
action:
- device_id: bcb34f3c2c8547e4bc2e11b5dd8a6b34
domain: light
entity_id: light.tradfri_bulb_e27_ws_opal_980lm
type: turn_on
Also the state home in the condition should be in quotes… it may work occasionally but it it supposed to be quoted. … maybe someone could provide the exact reason it is mentioned somewhere in the docs why… https://www.home-assistant.io/docs/automation/examples/
Also I’m not familiar with the action section looking like that… is that from the new automation editor?
That isn’t necessary. the way it is is perfectly fine.
I’m not entirely sure that is correct either. I realize that most examples put them in quotes (and it is good practice to do it I guess) but as far as I know the only states that absolutely require quotes are ‘on’ or ‘off’. And I’m assuming that they used the device automation editor to create the automation so one would hope it would create the required syntax correctly. And lastly the second one works without quotes so that is a good indication they aren’t required.
It’s from the Device Automation Editor.
to the OP,
can you trigger the non-working one manually (by going to the developers tools->states and then click the circled-i to the left of the automation then click trigger in the pop-up that opens)?
It’s weird right… I just checked in my automation yaml file and that is how I had them in there… and one of them at least came out that way from the editor… but yeah - weird
Both actions are the same (they both bring on the same bulb) a manual trigger should prove nothing. Can’t think of a valid reason why the different responses though.
I have had a couple of cases where I’ve had identical templates, one works one doesn’t. Each time I had hand copied them (not cut and paste) I went back cut and pasted the working one over the non working and hey presto, - nothing changed but the script now worked. I can only assume a rogue character or something. We used to use another blank character to pad spaces (not a space) to get message spacing right, can’t remember what it was and a bugger to debug, could be one of them?
(guessing and postulating and flapping about in the dark)
quotes are only needed for on and off when they are fields. Home assistants yaml parser converts them to true/false naturally, so to keep them as ‘on’, ‘off’, one must wrap them in quotes. In all fields that accept strings, quotes are optional unless you have characters that define a json object as the first character in the string. Then you’re required to have quotes because the parser assumes its a json object and not a string.
field: quotes_optional
'on': quotes_required_around_field
'off': quotes_required_around_field
field: '[quotes_required'
field: '{quotes_required'
field: 'on' #optional, but without quotes converted to true/false for on/off.
That should throw an error in the config checker if that’s the case. At least it has for me in the past and even a few days ago where I copied from another source that had a hidden tab in it.
It gave me an error along the lines of “/t can’t begin any token”.
I copy&pasted the working one - now both automations are triggered.
Still strange…
A bit confusing as I’m just starting with automations, and always not sure if it’s the server or if it is my fault.