Very new to Home Assistant. I’ve been learning a lot from the forums and docs, but I can’t seem to find the answer to this query.
- name: Dim Morning, Main Area
icon: "mdi:lightbulb-group"
entities:
light.living_room_pot_lights:
state: "on"
brightness: '{{ input_number.default_dimmer_3.dim.state | int }}'
switch.living_room_sconces: "off"
switch.living_room_chandelier: "off"
switch.living_room_accent_lights: "on"
switch.entrance_lights: "off"
I am trying to use the value of an input_number to set the value of the brightness in a scene. The scene is working, other than the brightness part. This is what I’ve cobbled together from a few other topics, but something is still missing. Thanks for your help.
The assumption here is that your input_number, representing brightness, is a number between 0 and 255. If it’s a number between 0 and 100 then change brightness to brightness_pct in the script below.
dim_morning_main_area:
alias: Dim Morning Main Area
icon: "mdi:lightbulb-group"
mode: single
sequence:
- service: light.turn_on
target:
entity_id: light.living_room_pot_lights
data:
brightness: "{{ states('input_number.default_dimmer_3') }}"
- service: switch.turn_on
target:
entity_id: switch.living_room_accent_lights
- service: switch.turn_off
target:
entity_id:
- switch.living_room_sconces
- switch.living_room_chandelier
- switch.entrance_lights
If I may bug you one more time, I am using brightness_pct, but it is asking for a float. I have tried to change it to "{{ states('input_number.default_dimmer_3') | float }}" as per the example above where it was converted to an int, but that doesn’t seem to work either.
The pot lights never actually turn on. All the other switches are responding as expected.
The template shouldn’t require a filter to convert the input_number’s value to float (or int) because Home Assistant’s native typing feature will interpret the value correctly. However it will fail if the input_number’s entity_id is incorrect. Double check the entity_id’s spelling.
In the following version, the input_number’s value is reported as an integer. If the input_number’s entity_id is incorrect, the int filter will report 0 as the default value. In other words, it will turn off the light.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.