Switch don't stick to their entity id on restart

Hi all,

I’ve got a couple of d-link DSP-W215 plugs and I’ve connected both of these. They are working fine. However, when I assign them friendly names and to groups they seem to switch config every time I restart. That is if I assign “Floor Lamp” to my living room group and “Side Lamp” to my bedroom group, next time I restart I will find “Side Lamp” in the living room and “Floor Lamp” in the bedroom - If I toggle “Floor Lamp” it will toggle the bedroom switch.

My configuration.yaml contains:

switch floor_lamp:
    platform: dlink
    host: 192.168.1.72
    username: admin
    password: 767481
    use_legacy_protocol: true

switch side_lamp:
    platform: dlink
    host: 192.168.1.68
    username: admin
    password: 475703
    use_legacy_protocol: true

These then show up as switch.dlink_smart_plug_w215 and switch.dlink_smart_plug_w215_2, its seemingly impossible to determine which is actually which.

Not sure if it makes any difference, but originally I had these configured under the same “parent” of switch and they were not named.

Is there some way to make the deterministic?

Is there a reason you don’t have it this way:

switch
  - platform: dlink
    name: floor_lamp
    host: 192.168.1.72
    username: admin
    password: 767481
    use_legacy_protocol: true

  - platform: dlink
    name: side_lamp
    host: 192.168.1.68
    username: admin
    password: 475703
    use_legacy_protocol: true

I think this way is more common. If you want to keep it the way you had it, then at least add the name parameter:

switch floor_lamp:
    platform: dlink
    name: floor_lamp
    host: 192.168.1.72
    username: admin
    password: 767481
    use_legacy_protocol: true

switch side_lamp:
    platform: dlink
    name: side_lamp
    host: 192.168.1.68
    username: admin
    password: 475703
    use_legacy_protocol: true

I think that will work, too, but honestly, I don’t use this format.

1 Like

This appears to fix the issue, thank you!

I originally had that first config and was then trying to switch things up to fix my issues. I’ve changed it back now.

I wasn’t aware that it could take a name as this wasn’t in the example config. Does this mean all entities can take the name parameter?

Unfortunately there’s some inconsistencies. Best to check the docs. E.g., here it shows that name is an optional parameter for a D-Link Switch (even if it doesn’t use it in the example at the top):

1 Like