How to use friendly_name for an hardware switch in automations.yaml

I’m new to zigbee2mqtt and have setup HA on a raspberry PI 4 with a SONOFF 3.0 Zigbee dongel.
Now i want control a light (led) with an hardware switch "Ecodim ED-10015.
With the configuration below i can switch on the light.

Part of zigbee2mqtt configuration.yaml

Devices:
  # hardware switch
  '0xb4e3f9fffeefac07':
    friendly_name: badkamer_ecodim_schakelaar_8_knoppen
    description: Schakelaar voor bedienen lampen in de badkamer
  # led light  
  '0xa4c138b20348eb1e':
    friendly_name: test_led_spot
    description: Deze led spot wordt gebruikt voor test doeleinde.

Automations.yaml

- id: '1799208799489'
  alias: test schakel lamp aan-uit
  description: testing
  trigger:
  - platform: device
    domain: mqtt
    device_id: 7cdb9a09b782b3da28c3d92144830a0d
    type: action
    subtype: on_1
  condition: []
  action:
  - service: light.turn_on
    target:
      entity_id:
      - light.test_led_spot
    data: {}
  mode: single

Now i want to use the friendly_name instead of the device_id in my automations.yaml but i know how to do that.
By everything i tried i get error messages or the light don’t switched on.
Can someone point me to the right direction how to get this to work?

Please format your post properly.

You can’t. But you could use a state trigger instead.

I suggest you read this before proceeding any further Why and how to avoid device_ids in automations and scripts

1 Like