Convert "input_number" to a "template light"

omg, this is working
thnx so much!! whay do i ow you ? :slight_smile:

1 Like

Nothing, I kinda wanted to know how to do this myself and you forced me to figure it out.

hehe, cool :slight_smile:

Petro, your code is working well, except 1 small issue i think

most brightness levels are working, like 10% , 60% , but if i use 40% nothing happens ā€¦
i think my controller doest accept maybe all numbers

can i change the code below, so it is always rounded to 10 20 30 40 ā€¦ 90
so if brightness is for example : 40% => so (102/255) * 90 = 36 => rounded to below = 30
so if brightness is for example : 80% => so (204/255) * 90 = 72 => rounded to below = 70
ā€¦

{{ '%02.f'%((states('input_number.dimmer1') | float / 255 ) * 90) }}

or maybe another approach, but back the sliders to 0 - 90 , steps 10, instead of 0 - 255

then change the formula in code below ? like ?
value: "{{ (brightness / 255) * 90}}"

  set_level:
    - service: input_number.set_value
      data_template:
        entity_id: input_number.dimmer1
        value: "{{ brightness }}"

The slider has to be 0-255 to mimic a light slider.

Try this equation:

{{ '%02.f'%((((states('input_number.dimmer1') | float / 255 ) * 90) // 10) * 10) }}

it essentially rounds your number every 10% of the bar with only the very top number being 90.

This equation rounds so that first and last 5% of the are zero, and full brightness. Everything between is in 10% increments.

{{ '%02.f'%(((((states('input_number.dimmer1') | float / 255 ) * 90) / 10 ) | round(0) ) * 10) }}

ok, you are my hero :slightly_smiling_face:

tried the first one, and working perfect now

Iā€™m in a similar boat:

input_number:
  soundbar_volume:
    name: Soundbar Volume
    min: 70
    max: 100
    icon: mdi:volume-high

I need to create a template light that controls this. Any help? Thanks.