Hello,
I am trying to write my first non-UI automation. I have some Tuya Bluetooth controlled shutters. I can control these in my dashboard. They do not always respond on the first try however. Why, is another topic to be explored at a later date. Now I am testing an automation that will keep trying to close the shutters (position 0) until they are closed with an interval of 10 seconds between each attempt. The automation is unavailable due to a formatting error (?) or ?. The message in the UI is:
Automation is unavailable
Actions: required key not provided @ data[0][ârepeatâ][âsequenceâ]
another thing to help you on your journey on writing more interesting code⌠avoid using device_idâs. use friendly entity idâs. itâll be a big help to youâŚ
@Didgeridrew@armedad Thank you both for your replies. They are appreciated! I am using the Studio Code Server addon and it seemed like it was flagging my spacing errors but I guess not all of them. I donât code in Phyton so âspacing as syntaxâ is not something I am used to. I made the changes as best I understood them but still getting an error I donât understand.
Automation is unavailable
Actions: offset None should be format âHH:MMâ, âHH:MM:SSâ or âHH:MM:SS.Fâ for dictionary value @ data[0][ârepeatâ][âsequenceâ][1][âdelayâ]
@armedad Yes, device ids are ugly and not desirable. I tried using a template(?) to get rid of them but I was making some kind of mistake. I decided to first get a syntactically correct automation first. I will come back to the ids.
something iâd really encourage you to do⌠because using us to debug your code is going to be a long slow road⌠use the ui. take your code, paste it into a blank automation, then flip it to the UI and see if it does what you want.
you would have seen that the delay time went to 0. it rejected your 10. then when you put 10 in and flip it back to the yaml, youâd see that it got indented.
the UI will find issues for you and will teach you at the same time.
you donât use a template to get rid of it. you use the entity_id friendly names. like light.living_room and switch.heater
it makes things way more readable to you. also as a bonus, home assistant will autocomplete for you when you type light. youâll never go back once you start converting over.
@armedad The documentation says not to edit the automations.yaml file that has the UI automations so I have them in another folder. Apparently that means I cannot edit them in the UI:
I almost never edit the automations.yaml directly unless Iâm doing a mass search and replace⌠Too easy to screw something up accidentally. Also no real benefit if you are just working on one yaml
btw there are lots of good reasons to do the programming in the UI, even if you are doing yaml only. For example The ui will recognize a bunch of changes and update it for immediate use, whereas if you do the automations.yaml you have to manually go reload it.
@armedad Well I tried using the friendly names for the entiy_id and now I have an error that I donât know how to fix. I change the entity name for one of the entities and there was no complaints.
None of the automations show an error.
When I run the checks in the developer tools, the YMAL configuration reloading.
All Yaml Configuration gives me this error:
Check all the others below give me the green check mark.
The âCheck Configurationâ give me what looks like the same error just written differently.
itâs not likely caused by using entity idâs. more likely that you fat fingered something along the way. did you do a mass change across all config? or did you just change this one function?
iâm also guessing you might have done direct edit to the .yaml file instead of going into the ui? (again, the ui will largely protect you against stuff like this)âŚ
Well it the automations file is source of the error.
But before I commented them out the automations list did not show any errors.
I guess I will work on it another day, up way too late already.