Hello everyone. I like to create a custom toggle automation, because I may not want to go back to the previous state - instead I like to switch on/off light with a certain brightness. I use a single switch, hitting it once shall turn on the light if it was in the ‘off’ state previously and vice versa.
I tried to use a service_template, but I have to deliver a “brightness” if the light.turn_on command was used. But! I’m not allowed to deliver the “brightness” if the light.turn_off command was used. Thus, I tried to use an additional data_template but I don’t have any succes with this. I’m getting all sorts of errors like “while scanning for the next token found character ‘%’ that cannot start any token”. This is surely just a syntax-error… Here is what I tried so far:
Thank you for looking at this. However, it’s still not working:
Starting with the light switched off, pushing the button lets the light turn on. Pushing the button a second time give the following error message:
[homeassistant.core] Invalid service data for light.turn_off: extra keys not allowed @ data[‘brightness’]. Got ‘’
I guess, that the keyword “brightness” is still present, but just without a value assigned… right? So in this case I have to hide the whole keyword “brightness” instead of its value… but how to do so?
Ah, you’re right. Brightness is not supported for light.turn_off, struggled with this also a while ago. It’s possible to ‘work around’ this with scenes, or make two automations…