I just get the following error, I’m editing the automation via the web front end and can’t remove the quotes (wondering if it’s a bug in the UI stopping me save it, or use fault:
Invalid service data for light.turn_on: expected int for dictionary value @ data['brightness']. Got '{{ states.light.t_room.attributes.brightness }}'
Context please, do you use this code sequence in a sensor, an automation or a script? Clearly “brightness” is expecting a integer value, not a string. The quotes around the template convert the result into a string, that’s what causing the error.
if you use {{ }} in any yaml configuration, it needs to be in an area that accepts a data_template of some sort. It looks like you are trying to use it in a service. If that’s the case, you need to use a data_template for said service:
But to me, that service doesn’t make sense because you are pulling the devices brightness and placing it into itself… which doesn’t make sense as devices inherently turn on with the last brightness level.
From a ‘whole picture’ standpoint, what are you trying to do?
I’m actually trying to put an if statement there to toggle the brightness, if it’s dimmed (i.e. 1) then set it to 255 otherwise set to 1. I have a binary switch that triggers this automation and does a number of things. This is the last step.