Simplest way to configure a switch to control a light (group)?

Can this be used?

You didn’t say what you are using in HA to manage your Zigbee devices are you still using Deconz with the Sonoff or are you using ZHA or Zigbee2MQTT? I know in Z2M there is the capability to configure this.

I didn’t know there were options! When I plugged my Sonoff in it was autodetected by HA and set up. It seems it’s using ZHA from the configuration url ( http://mydomain.tld:port/config/zha/dashboard?config_entry=xxxxxxxxxxxxxxxxxxx ) I’m not using Deconz at all any more.

I’m just looking for the simplest way possible.

I think that would be useful, although my main question is if there’s a simpler way to set up having my switch turn it off/on/change the brightness than setting up 4 automations for each group. I’ve edited my original TLDR to clarify.

OK, I use Zigbee2MQTT so I’m not sure ZHA also has this capability, my guess is not. I would try a Group or you can have your switch control a Scene as well that has all of the lights in it. I have a Zigbee button that I use to turn on 3 lights right now but I have a bit of a complicated setup as my Zigbee button has Single Press/Double Press/Hold options which I use as a way to turn on 1-3 bulbs at once.

OK, thanks for your reply @timnolte . My main question though isn’t really about groups at all. It’s whether there’s an easy way to get:

  1. The light switch on button to turn the light(s) on
  2. The off button to turn the light(s) off
  3. Holding the on button to increase brightness
  4. Holding the off button to decrease brightness.

…without having to set up a bunch of automations. I assumed there would just be a simple single way to say “light switch X controls light(s) Y” in HA, just as there is in Phoscon.

Am I missing something or does it just not exist and I need 32+ automations to dim and switch on / off the lights in 8 areas?

So, you should be able to this with 1 automation that will handle it all. However, for clarity in the single HA automation you’ll have some trigger handling to know if it’s the on or off button that is being pressed or held. So there will be like 4 different sets of logic all in 1. Setting up a Group will help to simplify the automation in terms of directing all of the lights. I’ll try to put together an automation tonight that should hopefully give you what you’re looking for.

1 Like

Thank you so much! I don’t understand how 4 different actions can be set up in 1 automation, but if it’s possible, that would be extremely educational both to me and others reading this post in the future, I’m sure.

If you set a group of lights in a light group then they should have the features of a light, like a service call to turn off, turn on, set brightness and possible also set color/temperature.

Yep. But my main question was how to set up 4 actions for each group (turn on, turn off, brightness up, brightness down) without needing a ton of automations (eg 32 automations for 8 groups).

@Synappz so here’s something to hopefully get you in the right direction. I don’t have all of the right hardware to get exactly what you need working. The smart bulbs I have are some WiFi bulbs that don’t properly support the transition. However, there are some resources linked below that should further help in that regard. I have a single button that I leveraged the single push & double push to mock up separate on & off buttons. In your case you’ll setup something like a switch-on-hold and switch-off-hold which will give you 2 sections where you will transition your brightness up (switch-on-hold) and then transition down your brightness (switch-off-hold). I created a Group helper that combines my 3 bulbs into a single entity so it makes it easier to setup in the automation. I’m not 100% on the right setup for the press-and-hold part to get it to keep incrementing the brightness until you release the button. I think you might be able to setup something with a Repeat Action and then use a condition that repeats until the button Release trigger. This may need more manual YAML work with some template usage in order to get it to function exactly like you are wanting. I might try playing around with this some more at some point but I’ve got some other project work to tackle yet tonight.

alias: Multi-Light Handler
description: ''
trigger:
  - platform: device
    domain: mqtt
    device_id: xxxxx
    type: action
    subtype: single
    discovery_id: xxxx action_single
    id: switch-on
  - platform: device
    domain: mqtt
    device_id: xxxxx
    type: action
    subtype: double
    discovery_id: xxxx action_double
    id: switch-off
  - platform: device
    domain: mqtt
    device_id: xxxxx
    type: action
    subtype: hold
    discovery_id: xxxx action_hold
    id: switch-hold
  - platform: device
    domain: mqtt
    device_id: xxxxx
    type: action
    subtype: release
    discovery_id: xxxx action_release
    id: switch-release
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: switch-on
        sequence:
          - service: light.turn_on
            data: {}
            target:
              entity_id: light.storage_room_lights
      - conditions:
          - condition: trigger
            id: switch-off
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.storage_room_lights
      - conditions:
          - condition: trigger
            id: switch-hold
        sequence:
          - service: light.turn_on
            data:
              transition: 300
              brightness: 255
            target:
              entity_id: light.storage_room_lights
    default: []
mode: single

Hopefully this will steer you in the right direction and others that may have a setup like yours can help fill in any gaps.

Thanks so much @timnolte ! Would a similar format work for ZHA as well, or would this require setting up an MQTT server and running everything through that?

You don’t need automations or HA light groups.

It can be done with zigbee groups and binding much like deconz. It’s actually pretty easy, just hidden a menu or two too deep.

1: Add the lights to a zigbee group via the “Groups” tab on ZHA Integration “Configure” page
2: Go to the “Manage Clusters” menu of the switch device and complete the “Group Binding” options.

Omg. Yes! This is exactly what I was looking for, but hadn’t come across the “binding” terminology to know what to search for:

The only thing is, when I select the group, tick the sections underneath, and click “bind group” nothing seems to happen. Another post said you need to click “Reconfigure” afterwards, but after closing the dialogue and clicking “Reconfigure” it just returns an error that binding failed and this in the logs:

[0xEC15:1:0x1000]: Couldn't get list of groups: Request failed after 5 attempts: <Status.NWK_NO_ROUTE: 205>

Feels like it’s close, though!

Start simple with just the OnOff cluster and add the others one at a time only if needed.

I never used a dimmer control under ZHA, just an on/off switch, but it should work.

I use Lutron Caseta for most of my lighting, and use zigbee2mqtt for zigbee, so not much I can test with under ZHA at the moment.

The automation I setup can be used with regardless of whether you are using ZHA or Z2M. I don’t have any Zigbee bulbs at the moment so I can’t test out binding, though I use Z2M and have no way to test ZHA if I had Zigbee bulbs.

I’m curious though if simple binding will get you the dimmer control that you are looking for.

oh my god. Thanks I’m not alone and you asked this.

I received my ConBee2 stick today and just set it up.

After about 30 minutes of creating automations for a zigbee switch (on, off, dim++, dim–, change color …) I think you know what I did - the same crap as you, I was sure that this must go better.

The UI does not make it easy to find this option - or I am simply blind.

I’m really thinking I ought to get my WiFi bulbs switched out for ZigBee ones. I haven’t been super impressed with the Meross WiFi bulbs I have, or at least the integration for them. :frowning:

I just discovered the solution to the error above! It seems that the devices go into some kind of power saving mode. If I push buttons on the IKEA switches while they’re reconfiguring, the reconfiguring works perfectly. Then the switches work great, changing the light groups. No automations needed! Thanks @jerrm for pointing me in the right direction in this reply!

Very useful thread, I couldn’t quite figure out bindings with my tradfri bulbs, but trigger IDs allowed me to map physical button presses to specific actions in a single automation very easily.