Currently, my Tuya ceiling light has a brightness sensor set up:
sensor:
- platform: template
sensors:
brightness_decke:
friendly_name: "Brightness Ceiling"
value_template: '{{ state_attr("light.ceiling", "brightness") * 1.5 }}'
This generally works… a second light (LED strip) is using an automation to change its brightness to match the ceiling light, but with a factor of 1.5, since I want it to be brighter than the ceiling light.
alias: LED Strip Brightness match
description: ''
trigger:
- entity_id: light.ceiling
platform: state
attribute: brightness
condition:
- condition: device
type: is_on
device_id: 6ef81025fd62944bce6a24193850779e
entity_id: light.ceiling
domain: light
action:
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 10
- data_template:
brightness: '{{ states.sensor.brightness_decke.state }}'
entity_id: light.led_strip_1
service: light.turn_on
mode: single
However, my log is repeatedly showing this:
TemplateError('TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'') while processing template 'Template("{{ state_attr("light.ceiling", "brightness") * 1.5 }}")' for attribute '_attr_native_value' in entity 'sensor.brightness_decke'
No matter if the light is on or not.
Any idea how to clean this up properly?