i’m new to home assistant & been trying to figure some stuff out.
In automation i’m trying to pass an entity_id to a script.
In the script i try to get the state of the passed entity & execute a service based on that state.
I don’t get errors, it just doesn’t do anything.
There used to be instructions at the top of the page but for some reason they have recently been removed. Basically, type a line containing just three “back ticks”, before and after the code. A “back tick” is the character that is typically the top-left most key on the keyboard. Looks like: `
So, first in your automation action, you can’t put a parameter name inside a template. Also, if you use the script name as the service you don’t need “variables:”. Lastly, always have an else in the if statement, otherwise, if all if’s & elif’s are false, you’ll probably have problems. So it should look like this:
thanks your changes to the automation did the trick. my problem is solved now.
the reason i’m using a script, is because the logic behind group.toggle is crap imho. (= it toggles the individual devices inside the group, not the group as a whole).
I think the simplified script will have the same issue’s as the original group.toggle i’ve attempted.
Ok, missed that. Glad it’s working. Might want to change to homeassistant.turn_on and off in case you ever put a mix of switches and lights in the group.