Hoping someone can help me with this:
I have automation set up on my lights so that after there is no motion for X amount of time, they dim for 10 seconds before turning off. If during that dimming period there is motion then they go back to full brightness. My automation works fine, but I keep getting an error in my logs due to the condition that checks for the dimming brightness. I was wondering if I could re-write the condition somehow to prevent the error, but I can’t think how. I tried adding the if statement to no avail.
Error:
Error during template condition: UndefinedError: ‘mappingproxy object’ has no attribute ‘brightness’
Automation:
- alias: "Turn on bedroom with motion sensor day"
trigger:
- platform: state
entity_id: sensor.bedroom_motion
to: 'true'
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.bedroom_memory
state: 'off'
- condition: time
after: '10:00:00'
before: '22:00:00'
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.bedroom_ambient_light
below: '15000'
- condition: sun
after: sunset
after_offset: "-1:00:00"
action:
- service: homeassistant.turn_on
entity_id: light.bedroom_light
data:
brightness: 255
- alias: "Turn off bedroom when no motion in day"
trigger:
- platform: state
entity_id: sensor.bedroom_motion
to: 'false'
for: '00:01:00'
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.bedroom_memory
state: 'off'
- condition: state
entity_id: light.bedroom_light
state: 'on'
- condition: time
after: '08:00:00'
before: '22:00:00'
action:
- service: homeassistant.turn_on
entity_id: light.bedroom_light
data:
brightness: 104
- delay: '00:00:10'
- condition: state
entity_id: sensor.bedroom_motion
state: "false"
- service: homeassistant.turn_off
entity_id: light.bedroom_light
- alias: "Re-activate light day time"
trigger:
- platform: state
entity_id: sensor.bedroom_motion
to: "true"
condition:
condition: and
conditions:
- condition: template
value_template: '{% if states.light.bedroom_light.state %}{{ states.light.bedroom_light.attributes.brightness | float == 104 }}{% endif %}'
- condition: time
after: '08:00:00'
before: '22:00:00'
action:
- service: homeassistant.turn_on
entity_id: light.bedroom_light
data:
brightness: 255