Input slider won't work

I would want to use slider to dimmer the light, so the following are my config…

configuration.yaml:

input_number:
  lamp_bright:
    name: Dimmer
    icon: mdi:lightbulb
    initial: 0
    min: 0
    max: 255
    step: 10

automations.yaml:

- id: hue_soggiorno_slider
  alias: hue_soggiorno_slider
  trigger:
  - platform: state
    entity_id: input_slider.lamp_bright
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.soggiorno
      data:
        brightness: >-
          {{ states.input_number.lamp_bright.state | int }}

If I put {{ states.input_number.lamp_bright.state | int }} in the template dev tools I see the right value, but it seems that the event isn’t fired… why?

your trigger is not input_slider.lamp_bright but input_number.lamp_bright.

2 Likes

I got this error on the log…

Invalid service data for light.turn_on: expected int for dictionary value @ data['brightness']. Got '{{ states.input_number.lamp_bright.state | int }}'

… why? in the dev tools template the string works!

Solved… I made an error on

  - service: light.turn_on
    data_template:
      entity_id: light.soggiorno
      data:
         transition: 30
         brightness: 64

… the correct version are …

  - service: light.turn_on
    data_template:
      entity_id: light.soggiorno
      transition: 30
      brightness: 64