Zigbee2MQTT - Change device type from switch to light

I have a few ZBMINIL2 from SONOFF and they get integrated as switch, instead of as light.

I know I can change the switch to light using HA, but it’s annoying because it creates a helper entity.

I’ve modified the Z2M configuration to this:

devices:
  "0x30fb10fffe6e9e0d":
    type: light

But it doesn’t seem to be doing anything. Does anyone know of a correct syntax that would do this?

Try single quotes, all the examples have single quotes.

I actually found Home Assistant | Zigbee2MQTT but it does not work.

The presented syntax looks like this:

devices:
  "0x12345678":
    friendly_name: my_switch
    homeassistant:
      switch:
        type: light
        object_id: light
      light:
        name: null
        value_template: null
        state_value_template: '{{ value_json.state }}'

That wasn’t the page I got the suggestion from, but it looks like the single/double quote thing was a red herring.

So does the setting you just posted work?

it is like this, look at the quotes:

  '0x0c4314fffeb51643':
    friendly_name: slaapkamer
    homeassistant:
      switch:
        type: light
        object_id: light
      light:
        name: licht_slaapkamer
        value_template: null
        state_value_template: '{{ value_json.state }}'

Applied your change (with a name for light – licht_slaapkamer), but it still shows up as switch.my_switch in the MQTT integration.

Where are you adding the config for ‘0x0c4314fffeb51643’?

Mine is in the configuration of the Z2M addon, like:

serial:
  port: /dev/ttyUSB0
zigbee_herdsman_debug: false
devices:
  "0x30fb10fffe6e9e0d":
    friendly_name: my_switch

The thing with " vs ', is that I save it with single quotes, but after restart it gets translated to double quotes.

Edit: I removed and re-paired the device after the Z2M restart. I’ve also restarted Z2M without re-pairing and it still shows up as switch.my_switch instead of light.my_switch

Edit2: Well, this is odd. Looks like /config/zigbee2mqtt/devices.yaml does not have my changes from the Z2M addon?

/config/zigbee2mqtt/configuration.yaml does this:

devices:
  - devices.yaml

Yet in my Z2M Addon I don’t have a “load”. What…?

Editing /config/zigbee2mqtt/configuration.yaml (and devices.yaml) solved this!

Why is the configuration from the addon page itself not being taken into account?

Just for future reference, if you are editing the configuration.yaml, this must be done with Z2M down, otherwise it will overwrite your settings again.

1 Like

I confirm that the configuration.yaml is the right place to make the adjustments. It worked for me with first stopping the Z2M add-on, editing the config, and then restarting the add-on together with reloading of the HA configuration.