SOLVED Input number, Slider

Hi there. I’m “new” to hassio coming from vera.
Really enjoying it and so far my setup is good.

Hopefully someone can help me with the following. I have setup input sliders for my lights and have been struggeling to get them to update in the ui.
Finally it works, almost…with this config it is updating, but not linear with the “original” slider, it’s only showing values between 0-85 :exploding_head:

My config:

input_number:

office_light_brightness:
name: Brightness
initial: 100
min: 0
max: 100
step: 5
icon: mdi:brightness-auto

automations:

##############################################################

Office Light Slider

##############################################################

  • alias: “Office Light Brightness”
    hide_entity: true
    trigger:
    platform: state
    entity_id: input_number.office_light_brightness
    action:

    • service: light.turn_on
      data_template:
      entity_id: light.kontor_2
      brightness: ‘{{ states.input_number.office_light_brightness.state | int * 2.55 | round(0) }}’
  • alias: Office Slider Get
    trigger:
    platform: state
    entity_id: light.kontor_2
    action:
    service: input_number.set_value
    data_template:
    entity_id: input_number.office_light_brightness
    value: ‘{{ states.light.kontor_2.attributes.brightness | float / 2.55 | round(0) }}’

I’m a little confused at what you’re trying to attempt. Are you trying to make 1 slider value equal to another?

Why are you using int * 2.55 and float?

If I get it right, you want a slider that you slide and it changes the brightness of your office lights?

+1 forsquirel; also what is ‘original’ slider?

1 Like

Yes, sorry it that was alittle unclear.
I have created a slider in the ui, so i dont have to click twice on the light to access the slider, if that makes sense to you?

Now I just realized that both sliders will only go max 85?? Without the “Office Slider Get” automation they both go to 100…

Sorry guys, this a little “learning by doing” for me. Most of my stuff, I have figured out from reading and google… I guess the int * 2.55 and float comes from my wish to have a slider from 0-100…

Just use brightness_pct instead of brightness? That way 100 is 100%

Thanks man, tried with the _pct, and both sliders are working. But the slider in the frontend (which i have created) is still not updating…

  • alias: “Office Light Brightness”
    hide_entity: true
    trigger:
    platform: state
    entity_id: input_number.office_light_brightness
    action:

    • service: light.turn_on
      data_template:
      entity_id: light.kontor_2
      brightness_pct: ‘{{ states.input_number.office_light_brightness.state }}’
  • alias: Office Slider Get
    trigger:
    platform: state
    entity_id: light.kontor_2
    action:
    service: input_number.set_value
    data_template:
    entity_id: input_number.office_light_brightness
    value: ‘{{ states.light.kontor_2.attributes.brightness.state }}’

Yeah, I can’t get it to work with % either. But I got it working with brightness. Both sliders change, when I change one of them.

Automation:

- id: '1528751771536'
  alias: Office lights
  trigger:
  - entity_id: input_number.office_light_brightness
    platform: state
  condition: []
  action:
  - data_template:
      brightness: '{{states.input_number.office_light_brightness.state | round(0)}}'
      entity_id: light.yeelight_color_ceiling_lamp_bedroom
    service: light.turn_on
- id: '1528753102452'
  alias: Office Slider Get
  trigger:
  - entity_id: light.yeelight_color_ceiling_lamp_bedroom
    platform: state
  condition: []
  action:
  - data_template:
      entity_id: input_number.office_light_brightness
      value: '{{states.light.yeelight_color_ceiling_lamp_bedroom.attributes.brightness | round(0)}}'
    service: input_number.set_value

Remember to change your entity id’s and values back to your own.

I twisted my head last night and finally got it working perfectly, with % and a scale on the slider showing 0-100. The trick was to create a template sensor for the brightness.

For anyone else searching for this topic i’m posting my config:

input_number:

    office_light_brightness:
      name: Brightness
      initial: 100
      min: 0
      max: 100
      step: 5
      icon: mdi:brightness-auto

sensor:

#############################################################
#
#            Brightness Office Light
#
#############################################################

  - platform: template
    sensors:
      light_office_2_brightness:
        friendly_name: 'Office Brightness'
        value_template: '{{ states.light.kontor_2.attributes.brightness | int / 2.55 }}'
        unit_of_measurement: '%'

automations:

##############################################################
#
#                Office Light Slider
#
##############################################################
- alias: "Office Light Brightness"
  hide_entity: true
  trigger:
    platform: state
    entity_id: input_number.office_light_brightness
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.kontor_2
      brightness_pct: '{{ states.input_number.office_light_brightness.state }}'

- alias: Office Slider Get
  trigger:
    platform: state
    entity_id: light.kontor_2
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.office_light_brightness
      value: '{{ states.sensor.light_office_2_brightness.state }}'
2 Likes
################################################################
## Packages / Kitchen Ceiling lights
################################################################

# homeassistant:
#   customize:

input_number:
  - kitchen_light_brightness:
      name: Brightness
      initial: 100
      min: 0
      max: 100
      step: 5
      icon: mdi:brightness-auto

#############################################################
#
#            Brightness Kitchen Light
#
#############################################################
sensor:
  - platform: template
    sensors:
      kitchen_light_2_brightness:
        friendly_name: 'Kitchen Brightness'
        unit_of_measurement: '%'
        value_template: >-
          {{ states.switch_keukenlicht.attributes.brightness | int / 2.55 }}


##############################################################
#
#                Kitchen Light Slider
#
##############################################################

automations:
  - alias: "Kitchen Light Brightness"
    hide_entity: true
    trigger:
      platform: state
      entity_id: input_number.kitchen_light_brightness
    action:
      - service: switch.turn_on
        data_template:
          entity_id: switch_keukenlicht
          brightness_pct: '{{ states.input_number.kitchen_light_brightness.state }}'

  - alias: Kitchen Light Slider Get
    trigger:
      platform: state
      entity_id: switch_keukenlicht
    action:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.kitchen_light_brightness
          value: '{{ states.sensor.kitchen_light_2_brightness.state }}'

Hi, sorry to start this post again, but I can’t get my head around it. I used ‘delete’ his/her code but my config won’t validate it. What am I missing?

Thats not a valid entity id in there. You’re missing the domain. I’m guessing it should be

states.light.switch_keukenlicht.attributes.brightness
1 Like

################################################################

Packages / Kitchen Ceiling lights

################################################################

homeassistant:

customize:

input_number:
kitchen_light_brightness:
name: Brightness
initial: 100
min: 0
max: 100
step: 5
icon: mdi:brightness-auto

#############################################################

Brightness Kitchen Light

#############################################################
sensor:

  • platform: template
    sensors:
    kitchen_light_2_brightness:
    friendly_name: ‘Kitchen Brightness’
    unit_of_measurement: ‘%’
    value_template: >-
    {{ state_attr(‘switch.keukenlicht’, ‘brightness’) | int / 2.55 }}

##############################################################

Kitchen Light Slider

##############################################################
automations:

  • alias: “Kitchen Light Brightness”
    hide_entity: true
    trigger:
    platform: state
    entity_id: input_number.kitchen_light_brightness
    action:

  • service: switch.turn_on
    data_template:
    entity_id: switch.keukenlicht
    brightness_pct: “{{ states(‘input_number.kitchen_light_brightness’) }}”

  • alias: Kitchen Light Slider Get
    trigger:
    platform: state
    entity_id: switch.keukenlicht
    action:

  • service: input_number.set_value
    data_template:
    entity_id: input_number.kitchen_light_brightness
    value: “{{ states(‘sensor.kitchen_light_2_brightness’) }}”

Thanks Petro for the reply, changed it and some other settings, yet still not correct… What do I miss?

Sorry for the messy layout.

1 Like

the switch domain does not have a brightness attribute, so this will never work.

{{ state_attr('switch.keukenlicht', 'brightness') | int / 2.55 }}

Thanks for the reply. Is there any way to convert a switch component into a component, like light, to use brightness?
The switch is a Shelly1, and I have a LED light connected to it. The light is dimmable so I would like to know what to make of it to get it dimmable, so the brightness component to work.

how is it integrated into HA? What component?

I have MQTT component active on the Shelly1 and integrated it as a switch.

Change it to an MQTT light.

You’ll need to add brightness to your topic or a separate topic. And you’ll need your device to interpret the topic.

Thank you!! Totally forgot that component. Thanks for adding the extra info regarding the topic.
I hope to figure this out and will let ya know the outcome.