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.
Good point. I picked that at random. Unfortunately it was one of my early automations. However I do the opposite and always make them the same now for precisely that reason.
I’ve never seen it. I think it is assumed knowledge that strings are quoted numbers aren’t. Could be in the YAML specification (i.e. not just for home assistant but everything that uses YAML).
Scott this is “your” thread we appear to have hi-jacked, the discussion seems to be relevant to you so that’s great, but it is we who should be appologising to you (not enough that we’ll stop though :cough: )
Automation IDs…if I create my own within the configurator, the UI editor does not recognize that it can be edited. So unless you create the automation in the editor, I guess adding such in the configurator doesn’t matter. As you said, time to get rid of the those IDs