Struggling to Mirror Lights

First post here.

I have been dabbling in HA (running in an ESXi VM) the last couple months when SmartThings announced my hub was being deprecated (ST/ADT hub).

I’ve been slowly moving over my devices but have hit a snag where I didn’t expect one. I have a z-wave diming switch that I had mirrored to a Hue white bulb. This allowed me to use the physical z-wave switch to turn on/off the overhead light and the floor lamp at the same brightness. I’ve read several posts about trying to replicate this and I’ve tried the ideas but nothing has worked. Below is the last example I tried, I’d love some help in getting this working.

- action:
  - service: light.turn_on
    entity_id: light.living_room_lamp
    data_template: 
      brightness: '{{ states.light.in_wall_dimmer_switch_5.attributes.brightness }}'
  alias: Living Room Lamp On
  id: living_room_lamp_on
  trigger:
  - entity_id: light.in_wall_dimmer_switch_5
    platform: state
    to: 'on'
  - platform: template
    value_template: '{{ states.light.in_wall_dimmer_switch_5.attributes.brightness }}'
    
- action:
  - entity_id: light.living_room_lamp
    service: light.turn_off
  alias: Living Room Lamp Off
  id: living_room_lamp_off
  trigger:
  - entity_id: light.in_wall_dimmer_switch_5
    platform: state
    to: 'off'

Try this:

- alias: Living Room Lamp Mirror
  id: living_room_lamp_mirror
  trigger:
    - platform: state # this will trigger on all state and attribute changes
      entity_id: light.in_wall_dimmer_switch_5
  action:
    - choose:
        - conditions:
            - condition: state
              entity_id: light.in_wall_dimmer_switch_5
              state: 'off'
          sequence:
            - service: light.turn_off
              entity_id: light.living_room_lamp
        - conditions:
            - condition: state
              entity_id: light.in_wall_dimmer_switch_5
              state: 'on'
          sequence:
            - service: light.turn_on
              data:
                entity_id: light.living_room_lamp
                brightness: "{{ state_attr('light.in_wall_dimmer_switch_5', 'brightness') }}"

One issue with your original “light on” triggers was that the template did not resolve to true or false as required for template triggers. This:

  trigger:
  - entity_id: light.in_wall_dimmer_switch_5
    platform: state
    to: 'on'
  - platform: template
    value_template: '{{ states.light.in_wall_dimmer_switch_5.attributes.brightness }}'

Would never trigger on brightness change. This would:

  trigger:
  - entity_id: light.in_wall_dimmer_switch_5
    platform: state
    to: 'on'
  - platform: state
    entity_id: light.in_wall_dimmer_switch_5
    attribute: brightness

Thank you Tom, appreciate you taking a look at this. I’m getting these errors, feeling beat up by this:

2021-03-29 18:14:20 ERROR (SyncWorker_5) [homeassistant.util.yaml.loader] while parsing a block collection
in “/config/configuration.yaml”, line 11, column 3
expected , but found ‘?’
in “/config/configuration.yaml”, line 14, column 3
2021-03-29 18:14:20 ERROR (MainThread) [homeassistant.components.hassio] Error loading /config/configuration.yaml: while parsing a block collection
in “/config/configuration.yaml”, line 11, column 3
expected , but found ‘?’
in “/config/configuration.yaml”, line 14, column 3

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

    # Text to speech
tts:
  - platform: google_translate            
  
# Sync Living Room Lights
  alias: Living Room Lamp Mirror
  id: living_room_lamp_mirror
  trigger:
    - platform: state # this will trigger on all state and attribute changes
      entity_id: light.in_wall_dimmer_switch_5
  action:
    - choose:
        - conditions:
            - condition: state
              entity_id: light.in_wall_dimmer_switch_5
              state: 'off'
          sequence:
            - service: light.turn_off
              entity_id: light.living_room_lamp
        - conditions:
            - condition: state
              entity_id: light.in_wall_dimmer_switch_5
              state: 'on'
          sequence:
            - service: light.turn_on
              data:
                entity_id: light.living_room_lamp
                brightness: "{{ state_attr('light.in_wall_dimmer_switch_5', 'brightness') }}"

This line tells Home Assistant that your automations are located in a separate file:

automation: !include automations.yaml

However, you pasted tom_I’s example into your configuration.yaml file.

Remove it from there and add it to the automations.yaml file. In addition, you left out the leading hyphen on the first line (don’t forget to add it, as shown in tom_I’s example).

Once that’s done, execute Configuration > Server Controls > Check Configuration. If it passes, execute Reload Automations.

Brilliant, working now! Thank you both so much for helping a beginner out, I’ve got a lot to learn.