I made the move from a homebridge setup to home assistant running on a raspberry pi last week. There’s been a small learning curve but, on the whole, it’s an easy platform to use—and gives way more control over automations (but you already know that).
Anyway, due to the minor differences on how Hass works, I’ve set up my scenes as scripts but I didn’t like the way they were displayed. I played around with input_booleans but, in the end, settled on input_selects (to save real estate). I have multiple input_selects (for different rooms) and an automation for each scene which is triggered if any of the input_selects chooses the scene. Maybe someone has a better approach?
I’ve also set a ‘master brightness’ input_number with the aim of adjusting the brightness for the entire house (which can be automated depending on light level, time of day, etc). I’ve created a scene/script which sets the hue & saturation and checks the value of the master brightness to set the scene brightness. When I use templating to look up the value, nothing happens. When I explicitly state the value, it works fine.
I’ve checked the templating format using the web interface and everything appears to work fine. I also have another script that uses the exact same method to set a timer and that works fine so I’m not sure where I’ve gone wrong with this one. I need a fresh pair of eyes.
Here’s the script that runs the scene:
peaches_and_cream_script:
alias: Peaches & Cream (script)
sequence:
- data:
brightness_pct: '{{ states.input_number.slider2.state | int }}'
entity_id: light.stuarts_desk_lamp
hs_color:
- 31
- 42
service: light.turn_on
- data:
brightness_pct: '90'
entity_id: light.right_uplighter
hs_color:
- 35
- 59
service: light.turn_on
- data:
brightness_pct: '90'
entity_id: light.left_uplighter
hs_color:
- 33
- 67
service: light.turn_on
- data:
brightness_pct: '90'
entity_id: light.fionas_desk_lamp
hs_color:
- 37
- 44
service: light.turn_on
- data:
entity_id: switch.fairy_lights
service: switch.turn_on
Here’s the automation that triggers when any of my input_selects are used to choose the Peaches & Cream scene:
- id: '1526473407210'
alias: Peaches & Cream Input Select
trigger:
- entity_id: input_select.fav_scenes
platform: state
to: Peaches & Cream
- entity_id: input_select.lr_scenes
platform: state
to: Peaches & Cream
condition: []
action:
- service: script.peaches_and_cream_script
service: script.1526475620973
All the second script does is set the input select back to the default option.
Here’s an example of one of my input_selects:
fav_scenes:
name: Favourite Scenes
options:
- ' '
- Peaches & Cream
- Kitchen Colours
- Relaxing
- Reading in Bed
- Footpath Chalk
- Tropical
- Night Night
icon: mdi:floor-plan
initial: ' '
And finally, the code for the input_number:
slider2:
name: "Master Brightness"
initial: 50
min: 0
max: 100
step: 1