In an action how can I set the state of a device equal to that of another

For example I have an input_slider and would like to set a light’s brightness value to the value of the slider.

automation:  
  - alias: hall light dimmer
    trigger:
      platform: state
      entity_id: input_slider.hall_light_brightness
    action:
      service: light.turn_on
      entity_id: light.upstairs_hall_1
      data:
        brightness: input_slider.hall_light_brightness.state

The above does not work. I saw the documentation about templating but was unsure about where and how it was supposed to be used. Is what I want to do possible?

I’m no expert and I’m at work so I cannot test , but wouldn’t it be something like this:

    action:
      service: light.turn_on
      entity_id: light.upstairs_hall_1
      data:
        brightness: {% input_slider.hall_light_brightness.attributes.brightness %}

That syntax does not seem to work. If I do that HA fails to start with a syntax error in configuration.yaml

May 06 13:19:19 raspberrypi systemd[1]: Started Home Assistant.
May 06 13:19:23 raspberrypi hass[3776]: ERROR:homeassistant.util.yaml:while scanning for the next token
May 06 13:19:23 raspberrypi hass[3776]: found character '%' that cannot start any token
May 06 13:19:23 raspberrypi hass[3776]: in "/home/pi/.homeassistant/configuration.yaml", line 147, column 22
May 06 13:19:23 raspberrypi hass[3776]: Config directory: /home/pi/.homeassistant
May 06 13:19:23 raspberrypi systemd[1]: [email protected] holdoff time over, scheduling restart.

Try quoting the template part

action:
      service: light.turn_on
      entity_id: light.upstairs_hall_1
      data:
        brightness: "{% input_slider.hall_light_brightness.attributes.brightness %}"

That does not work either. When I change the slider I get this in the log:

May 06 13:59:19 raspberrypi hass[4129]: INFO:homeassistant.core:Bus:Handling Event call_service[L]: service=turn_on, service_call_id=1979603472-2, service_data=brightness={% input_slider.hall_light_brightness.value %}, entity_id=[‘light.upstairs_hall_1’], domain=light>
May 06 13:59:19 raspberrypi hass[4129]: ERROR:homeassistant.core:Invalid service data for light.turn_on: expected int for dictionary value @ data[‘brightness’]

It appears to be sending the template string instead of a numeric value.

What I really want to accomplish is controlling several lights brightness with one slider. I have a fixture that has 5 hue bulbs in it. It is not practical to adjust each of the bulbs to the same brightness manually, I want to treat them as one light. See topic here Group Light Controls - #3 by GraysonPeddie

1 Like

For anyone else I figured this out or my situation:
Needs to be in this sort of format:

volume_level: '{{ states.input_number.virtual_fire_tablet_volume.state }}'