Hey all, fairly new to Home assistant. I’ve had an automation that has worked flawlessly for quite sometime but it suddenly stopped working today. I have home assistant running on a RP 3B. Automation is between a Xiaomi button and Philips hue lights, to turn them on and set brightness at the same time.
I am getting this error in ‘info’:
Error rendering service name template: UndefinedError: ‘mappingproxy object’ has no attribute ‘brightness’
Here’s the automation:
- id: turnon_bedroom_lights
alias: ‘Turn on bedroom lights’
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00016c101d
click_type: single
condition:
condition: state
entity_id: ‘light.bedroom’
state: ‘off’
action:
- service: light.turn_on
data:
entity_id: light.bedroom
brightness: 255
I can’t really think of any reason why this isn’t working, especially since it was working find yesterday. Another button that also calls light.turn_on with brightness is also not working. Any help would be greatly appreciated!
Thanks
Can you Submit your code using the Preformatted Text option the way you have it does not show it with correct indenting
Also try, brightness 254, I seem to recall an issue with specifying 255. Alternatively you can use brightness_pct: 100
if you really need that last 0.04 percent.
Not that it makes much difference but you do not need the condition you have it would be find to just have the condition blank as condition: []
- id: turnon_bedroom_lights
alias: 'Turn on bedroom lights'
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00016c101d
click_type: single
condition:
condition: state
entity_id: 'light.bedroom'
state: 'off'
action:
- service: light.turn_on
data:
entity_id: light.bedroom
brightness: 255
try this:
- id: turnon_bedroom_lights
alias: 'Turn on bedroom lights'
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d00016c101d
click_type: single
condition: []
action:
- service: light.turn_on
data:
entity_id: light.bedroom
brightness_pct: 100
Question for you what kind of Switch are you using is it a button? or is it a toggle switch that has a on and off position? If its a Button it might be better to use the light.toggel
VS light.turn_on
so you only have to have one automation VS two (one for on & one for off)
Thanks! It seems to be working again after restarting the RP several times but I’ve updated the automation for good measure. I’m using a button and I had it working with light.toggle but I couldn’t pass brightness information with that, hence the two separate automations with conditions.
Thanks a lot for your help!