AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.67k stars 414 forks source link

Sonoff SPM Switches change device_class #1178

Closed thomasfowler closed 1 year ago

thomasfowler commented 1 year ago

In my configuration.yml I have my default_class set to light, as I primarily have Sonoff light switches. However, I also have a SPF controlling and monitoring some devices in my household.

I would like to configure the switches on the SPM to come through as entities with the device_class switch rather than light.

Each of the light entities has the following entity_id on the SPM Sub-board:

  1. light.sonoff_ab30000101_1
  2. light.sonoff_ab30000101_2
  3. light.sonoff_ab30000101_3
  4. light.sonoff_ab30000101_4

As per the docs, in order to set the device_class in the configuration.yml "DeviceID is always 10 symbols string from entity_id or eWeLink app."

So, if I set the config as follows:

devices:
  ab30000101:
    device_class: switch

Only the first switch is now a switch entity with id switch.sonoff_ab30000101_1. The remaining 3 are still light entities with the ids noted above.

And if I use, for example, ab30000101_1, it is ignored.

How do I configure the integration such that all 4 entities device_class is switch?

sipimokus commented 1 year ago

@thomasfowler I don't use this function, but here is a description for multi channel devices, please check the readme: https://github.com/AlexxIT/SonoffLAN#custom-device_class

image
thomasfowler commented 1 year ago

Thanks for pointing that out. Not sure how I missed it in the docs....

For those who come across this, this was my solution that got it working:

devices:
  ab30000101:
      device_class: [switch, switch, switch, switch]