Light group with a smart plug

Hi guys

I’m new at HA, but I’m getting there, slowly :slight_smile: I hope you can help out a noob:

I have set up a bunch of light groups. One of the groups includes a smart plug (for a lamp which can’t be turned “smart” in any other way).

My lights.yaml:

- platform: group
  name: Basement Lights
  entities:
    - light.playbar_1
    - light.playbar_2
    - light.play_3
    - light.hugo
    - light.wiz_plug_1

I’m using Light Cards in my Lovelace UI in order to control the different groups. So far, so good.

basement

type: light
entity: light.grotten_lights
name: Basement

Everything works: Toggle lights, change color of lights and brightness slider.

Even though everything works, I’m getting this error when using the brightness slider:

Cant read response from the bulb. Debug: b'{"method":"setPilot","env":"pro","error":{"code":-32602,"message":"Invalid params"}}'

.....

File "/config/custom_components/wiz_light

So, this tells me that the “issue” originates from the plug/the plug (the plug is a Wiz Smart Plug), and I’m quite confident that I’m getting the error because I’m trying to ‘brightness slide’ a plug - which is, obviously, not possible.

Everything sort of works, so I COULD just go on and live with the error. However, I just hate errors in logs, so I would really love to have it fixed or set up the “right” way. The error is showing every time I use the brightness slider: Link to screenshot

Should I somehow convert the light.wiz_plug_1 to a switch? I don’t think the Light Cards are able to include switches? Maybe I’m wrong.

What do you guys think? Any solutions? Remember, I’m quite new at this - please go easy on me :slight_smile:

1 Like

No you can not use switch entities in light groups.

How did you convert the switch (smart plug) to a light (light.wiz_plug_1)?

Are you sure it is not a switch, switch.wiz_plug_1 ?

If it was set as a light by a setting in the plug try setting it to be a switch, then use this in home assistant to convert it to a new light entity:

Then try using that entity in your light group. Not tested - no guarantee it will stop the error occurring, but it’s worth a try.

Hi Tom

Thanks!

It popped up as a light - I didn’t do anything, I swear :wink:

Do I just rename the entity to “make it” a switch instead?

No, you can not change the domain of an entity like that, only the bit after the domain, the object_id is editable (in some cases).

domain.object_id

e.g.

light.my_light

The object_id my_light may be editable but the domain light. is not editable.

What sort of smart plug is it?

It’s a Wiz Smart Plug - cheap as hell: WiZ | Consumer | Products | Smart Plug

It’s a danish socket, fyi.

I’m thinking about fixing it by creating two automations where the plug follows the on/off state of other lights. Should work, but seems ugly.

Which integration did you use to bring the smart plug into home assistant?

I used this one GitHub - sbidy/wiz_light: A WiZ Light integration for Home Assistant

That appears to be for lights not smart plugs.

Yeah, i can see that now. However, it works… -ish :sweat_smile:

Ok so there is no way to import it as a switch so my idea is out the window.

This will work but you only need one automation.

Write the “on” automation and post it here and I’ll show you how to modify it to do both on and off.

Cool, thanks.

My on automation looks like this:

alias: Turn on Wiz
mode: single
trigger:
  - platform: state
    entity_id: light.basement_lights
    to: 'on'
condition: []
action:
  - type: turn_on
    device_id: fbcd123ad44177d8d14e7fb8xxxxxxx
    entity_id: light.wiz_plug_1
    domain: light

That should do it, right? For “on”, that is.

Yep. Change it to this:

alias: Turn Wiz on or off
mode: single
trigger:
  - platform: state
    entity_id: light.basement_lights
    to: 
action:
  - service: "light.turn_{{ 'on' if trigger.to_state == 'on' else 'off' }}"
    target:
      entity_id: light.wiz_plug_1

The null to: will trigger on any state change, but not attribute changes, of the basement lights.

Leaving to: out altogether will trigger on all state and attribute changes of the basement lights. You don’t want this or it will trigger every time you change the brightness or colour.

2 Likes

Awesome! Thanks a lot for your help :ok_hand:

@tom_l: It is not so uncommon that plugs pop up in the light domain instead of the switch domain.

An example are my Osram / Ledvance ZigBee plugs. If I connect them to HA using one of my Hue bridges they are added as lights. If I connect them using Zigbee2MQTT they come in as switches.

I guess it all depends what properties the plug advertises and how the coordinator interprets them.
So far I never had any issues with them. After all there are also many true lights that are only able the turn on and off without the ability to change brightness or color.

I will run some tests later putting these plug lights into light groups to see whether I can reproduce the error that Kasper has described.

2 Likes

Thanks for the info. I’ve only ever used smart plugs flashed with ESPHome or Tasmota. These were always switches. Though it would be possible to change that.

You definitely cant put switches in light groups. But if it is in the light domain it should work. This really seems like an issue with the Wiz light integration.

Just tried it like so:

light:
  - platform: group
    name: Test Plug Lights
    entities:
      - light.steckdose_buro
      - light.steckdose_wim1
      - light.kind_schiene

The first two lights are Osram plugs (“Steckdose” means “plug”).
The third is a real light that is dimmable. We need it so the group will expose a dimming slider.

The resulting group can be used as expected. The plugs switch on and off together with the light but ignore any dimming. Just like a non-dimmable light would do.

There are no errors in the logs. So I guess you are right @tom_l:
The Wiz integration tries to do some dimming on the plug and throws.

2 Likes