Thanks @tom_l, I do use that functionality through my Android Tasker app and plugin, so this will come in handy.
I’m running it as a VDI on my Windows computer. I’ll give both add-on’s a try. thanks.
If you use VS Code, I suggest using this extension:
https://marketplace.visualstudio.com/items?itemName=keesschollaart.vscode-home-assistant
Got Cloud9 running, though I get an alert in the log, which I have started a new thread here:
https://community.home-assistant.io/t/cloud9-log-alert/148621
Edit: Solved; guess all the add-on’s have this error; ignoring.
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.
If you install this vscode extension it will show you your indentation inconsistencies too:
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.
Off subject code question using vscode…
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?
- service: homeassistant.turn_on
entity_id: light.living_room_shelf_lamp
data:
brightness_pct: 50
transition: 3
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.
I’d make them completely different t
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.
- id: mains_power_fail_alert
alias: 'Mains Power Fail Alert'
initial_state: true
trigger:
One day when I have some spare time I may delete all the automation ids.
Using quotes…I now get it. Where is that in the docs? I tried searching for ‘using quotes’, etc. and could not find it.
ID’s, good to know I can name it, not just present a number. Probably a good thing to use it in case the UI editor becomes more robust someday.
Where is that in the docs?
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: )
All good; wanted to make sure this shouldn’t be a new thread as this has gone off-subject.
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
Well there you go. I’ve never tested it and learned something today. I am wasting my time with automation ids.
Tom, noticed while editing (with just the home assistant addon) that when you add a space it lets you, but when you backspace it takes out two (a tad inconsistent but I suppose that’s to allow normal writting, both for comments AND for just mid normal code … I would hope that rainbow allows the same … )
… off now to download rainbow and have a play with that.
From the discussion (Tom & Taras) I’m assuming that using multiple addon’s simultaneously is permitted ? So Home Assistant + Rainbow + Config Helper ??? (where do I find that ?)
Cheers
P.S. I don’t think you have saved me any time at all, I think I will now spend ages going through all my files (obviously with currently valid yaml) making all the spacing 100% consistent. Damn my OCD !