You’re not using the attribute “entity_id” when mentioning the light:
- id: '1573782707182'
alias: Night
description: ''
trigger:
- event: sunset
platform: sun
condition: []
action:
- data:
entity_id: light.living_room_shelf_lamp <--- I just made this entity up, you need to find yours
service: light.turn_on
- data:
entity_id: light.living_room_night <--- Same here.
service: light.lifx_set_state <--- I've also never heard of this service, but I don't have LIFX lights.
service.lifx_set_state is a valid service but if you review the documentation you’ll see it’s for calling the entity_id of one or more LIFX lights (not a scene).
The current state of the Automation Editor leaves lots of room for improvement. I recommend you learn how to use VS Code preferably with the Home Assistant extension. Are you currently using the HASS.IO version of Home Assistant? If so, VS Code is available as an add-on.
The set state service for a Lifx light allows you to change the attributes of the light (e.g. colour and brightness) without changing the state (on/off). For other manufacturer’s lights you can only change the brightness or colour when using the light turn on service.
I use the set state service set light brightness attributes depending on the outside light level. Then other automations turn the lights on/off triggered by movement.
Unfortunately it does not run on an RPi if that’s what @ScottS has Hass.io installed on. There’s a note about it in the known limitations section for the VSCode addon page.
However there is an extension for VS Code to connect a stand alone installation of VSCode to HA that works pretty well.
Even better - I really like the Cloud9 IDE addon. It’s the bees knees. Runs on a PI and has a built in terminal negating the need to run another SSH terminal addon. Addon installs it preconfigured for your HA instance.
Having read this, I installed vsc on win 10
Added the home assistant addon showed it where my files were and it went through and found two itty bitty faults in my files that check config missed.
That’s really quite impressive.
I also like that similar to notepad++, it does auto completion, but across all files and all entities.
Thanks for the recommendation.
The Config Helper extension also identifies indentation errors although maybe not as attractively as the ‘indent rainbow’ extension. In the following screenshot, I’ve added an extra space in front of friendly_name and immediately the last word on the line gets the’ wavy gravy’ treatment. By hovering over it, the popup reveal the cause is bad indentation.
Here’s the same indentation error but with the indent-rainbow extension installed. Wavy gravy + popup + super-obvious red bar.
The other cool thing about indent-rainbow is that it forces multiples of 2 spaces by default. So even though the following is ‘technically’ correct yaml it alerts you to a style inconsistency.
In the below code, the brightness setting (50) does not have single quotes around it, should it? VScode did not present an error for it.
I also do not have an id specified for this device. It’s my understanding that device id is no longer required as we’re now using the device name…correct?
the brightness setting (50) does not have single quotes around it, should it?
Nope.
A number is expected as the value. Depending on the key: sometimes a string is expected. You should quote these or if a special character like ‘%’ is used. Or a special word like ‘on’ or ‘off’ (unquoted these will evaluate to true and false).
Look at this part of the docs:
The VSCode extension is not aware of type (number vs string), just correct key: value pair syntax and indentation.
Home assistant can usually deal with a quoted number anyway.
IDs are a UI editor thing and can be omitted if you never intend to use it. I have a bad habit of including them in all my automations as I started out very briefly with the UI editor.
- id: lounge_lamp_green_flash # Not required unless using the UI editor, so why do I do it? Habit.
alias: 'Green Flash at Sunset'
trigger:
...
If you use IDs at all, I’d make them completely different than the alias. It’s very misleading when you go and try to figure out the name for your automation. Is it automation.lounge_lamp_green_flash? Nope. It’s the very un-intuitive automation.green_flash_at_sunset.
I tend to omit the IDs and write my aliases as they are going to be viewed in the dev states page. It’s easier to remember the name when you go to write things that use that automation, and it’s easier to find it in the code after seeing it refereneced in the HA log file.