Change device_id

Hello,

Still quit new to Home Assistant, and I have a question about this YAML-code.
I have this:

    then:
      - parallel:
          - type: turn_on
            device_id: e400ff770e3e65353b34216975ba2a5d
            entity_id: 602f17bf736f977bba17a27be84dd576
            domain: switch
          - type: turn_on
            device_id: 9264a7b8bc753ab01d15ec871e72f7e3
            entity_id: e6f1f722f7ae3499b5a49085e0274114
            domain: switch

How do I know which device has which device_id?
I have searched for these names, but can’t find how to change it to a more normal name.

These are Zigbee Power Plugs. And these have normal names like “Stekker 01 Kerstboom”.

I hope someone can help me with this.

Kind regards, Peter

Recommendation: Use entitles instead of devices in your automations.

2 Likes

Not both.

Can you find the device in Developer Tools → States. This shows a full list of all entities currently loaded. Look for your device by its name: switch.kitchen or something similar.

Just curious, how did you get this mess of an automation?

This is default if you use the GUI to create an automation and use the option “device - a great way to start”.

This results in the following code:

description: ""
mode: single
triggers:
  - type: turned_on
    device_id: 6cd8fedfc5b7d62f46c66e50dd3d261f
    entity_id: 9758196133e9b48e3207fc61b85574b6
    domain: light
    trigger: device
conditions: []
actions: []

@MoneyPeet take a look at this Why and how to avoid device_ids in automations and scripts

1 Like

Yes, that’s what I did.
As a beginner YAML is difficult to learn, and I think the GUI is a great way to start.
But when it comes to some more difficult settings, you need YAML.
And then you see all these ID’s and Devices with the long numbers.

Totally understandable - you can continue creating your automations in the GUI, by try with entities instead of devices (trigger using state), it will make a lot more sense to you when you look at the yaml :slight_smile:

This is a snip of an automation made in the GUI using entities and states, see how much more sense the naming makes:

description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.door_toalett_oppe_contact
    to: "on"
    id: dor open
  - trigger: state
    entity_id:
      - light.toalett_oppe
1 Like

So, a very simple example:
I have a Zigbee Power Plug. I want it to switch on at 20.00 hrs.
I can start with a simple When, and enter the time.
What do I enter at: Then do?
I don’t see the Entity there?

BTW, thanks for taking some time to help me.

From GUI: empty automation → add trigger → time → fill in details

Then do → find switch in the menu → turn on → add target → entities → your target

which translates to:

description: ""
mode: single
triggers:
  - trigger: time
    at: "20:00:00"
conditions: []
actions:
  - action: switch.turn_on
    metadata: {}
    target:
      entity_id: your switch
    data: {}

For lights you use the light action and so on

YEAH! Working,
Thank you so much, for the assistance so far.

alias: Test script with entitys
description: ""
triggers:
  - trigger: time
    at: "21:11:00"
conditions: []
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.power_plug_test
mode: single

2 Likes

Glad you got it working!

2 Likes