I’m trying out Home Assistant and I have a smart lamp that doesn’t have a Home Assistant integration, but it does support Google Assistant.
I’ve managed to create a light template for this lamp that calls Google Assistant to trigger events:
light:
- platform: template
lights:
office_lights:
unique_id: office_lights_template_001
friendly_name: "Office Lights"
# level_template: WIP
# value_template: WIP
# temperature_template: WIP
turn_on:
action: google_assistant_sdk.send_text_command
data:
command: turn on the office lights
turn_off:
action: google_assistant_sdk.send_text_command
data:
command: turn off the office lights
set_level:
action: google_assistant_sdk.send_text_command
data:
command: "{{ 'Set my office lights brightness to ' + (((brightness/255*100)|int)|string) + '%' }}"
max_mireds_template: 1000
min_mireds_template: 100
set_temperature:
action: google_assistant_sdk.send_text_command
data:
command: "{{ 'Set my office lights to ' + (((1000000/color_temp)|int)|string) + 'K' }}"
With this I can control the on/off, brightness and temperature events, but I would like to implement value_template and level_template as well, so that the state in the UI matches the actual state of the lamp. Thinkering with google_assistant_sdk_custom, I can ask about the state of my lamp and get a text answer (“Office light is on.”/“Office light is set to 100 percent brightness.”).
I’m stuck at: 1) how to call actions inside value_template and level_template to use the return variable as a value (if possible at all, or if there’s another correct way of doing it); and 2) how to extract the number from the text (should I use regex or another built-in function?).
I’m new to home assistant, so if there’s another way of doing what I need please let me know! Any help is appreciated!