I am trying to control a shelly bulb with a script.
It works, but not quite the way I want it.
I can turn the bulb on and off, but I also want to add the color and I can’t.
The style you are using is Device Automation and produced when you use the Device Automation editor. This style isn’t well documented so it’s challenging to create/modify manually (in fact, it’s been said that it wasn’t designed to be manually created/modified).
The traditional way is well documented and is service-oriented as opposed to device-oriented. This is an example of turning on a light and setting its color:
In the same place as the script shown in your first screenshot. What I suggested should replace the portion that lies outside the red box.
You should know that by posting screenshots of your code it makes it very inconvenient for others to provide you with working examples. We have to type everything shown in the screenshot. I’m not willing to do that so, in the future, to get better service from people trying to help you, please post your code as text, not a screenshot.
I notice that the config there is done there in configuration.yaml, while I was thinking in the direction of the two aforementioned configFiles. I guess I am on the wrong track and am happy with all your explanations.
Although everything can exist in one file (configuration.yaml), many people choose to separate it into multiple files, where each file represents either sensors, automations, scripts, scenes, etc.
For example, if I put this in configuration.yaml
script: !include scripts.yaml
I am instructing Home Assistant that my scripts are not in configuration.yaml but in a separate file called scripts.yaml. That’s what you appear to have done so that’s where you should continue to place your scripts, in scripts.yaml.
The use cases that I finally want to achieve is as follows:
I have a Z-wave door sensor.
If the door opens I want the bulb to flash green
If the door closes I want the bulb to flash red.
I created two automations that call a service if the door opens / closes - so far so good.
I implemented the use case by letting the automations trigger scenes that controls the bulb.
But Z-wave in combination with scenes seems not to be a good practice (resulting in errors) so now I am in the process of converting my scenes to scripts.
Is this a good approach?
I am struggling and fall from one problem to another……