This solution took a fair amount of fiddling for me, and in the end it works 20% of the way. When toggling the lightbulb off in Home Assistant, the light does turn off, but only after turning it on via the Alexa app.
The light cannot be turned on from HA, and even after turning it on in Alexa, the colour/brightness cannot be changed from HA.
The state also doesn’t seem to update in the Alexa app, when toggling the lights off in HA, until you tap on the light to ‘refresh’ it in the Alexa app. Then it ‘realises’ that the light has been turned off, and it appears in Alexa as off.
In the configuration.yaml you provided, don’t lines 7 and 8 need entity IDs and a service?
At least, for me, HA gave me yaml errors, until I added a service call and entity ID’s for turn_on / turn_off in the yaml:
light:
- platform: template
lights:
joes_office_light_1:
friendly_name: "Ceiling Light 1"
temperature_template: "{{states('input_number.temperature_input') | int}}"
color_template: "({{states('input_number.h_input') | int}}, {{states('input_number.s_input') | int}})"
turn_on:
service: light.turn_on
entity_id: light.joes_office_light_1
turn_off:
service: light.turn_off
entity_id: light.joes_office_light_1
set_temperature:
service: input_number.set_value
data:
color_temp: "{{ color_temp }}"
entity_id: input_number.temperature_input
set_color:
- service: input_number.set_value
data:
value: "{{ h }}"
entity_id: input_number.h_input
- service: input_number.set_value
data:
value: "{{ s }}"
entity_id: input_number.s_input'
The ‘turn off’ from HA seems to be working fine, but the ‘turn on’ gives the following error in Node-RED:
function : (error)
"TypeError: Cannot read properties of undefined (reading '0')"
The error is with the ‘function’ node, but I have no clue what’s wrong with it or what I need to change.
I also see some errors in Home Assistant itself:
Failed to call service light/turn_on. not a valid value for dictionary value @ data[‘entity_id’]
Failed to call service light/turn_on. extra keys not allowed @ data[‘color_temp’]
Do you have any suggestions?
I’m determined to make this work - my house is FULL of these bulbs!