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:
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.