One item with multiple switches - how to sync on/off

Hi,

I would like to solve the following problem:

I have a switched power outlet from Shelly and I want to switch it with three different switches from my BTicino home automation system.

For that I have created one “item” of type “switch” and linked it to the “Power” channel of the Shelly and also to all three “Switch” channels of the BTicino system. For the link to the Shelly I use the “follow” profile, for the switches the “default” profile.

So now to the problem: if the switch is off, I can switch it on with all three switches, that works fine. But then I can only switch it off with the switch I used for switching it on. If I want to switch it off with another, I have to put that particular switch to on first and then to off for the power to go off.

Is there any way I can set it up so that one switch can be used to turn the power on, and another then to turn it off?

Here is my item configuration:

Thanks for your help!

As a caveat, I’m not familiar with shelly outlets, nor how to handle items with multiple switch channels, nor am I entirely sure what you’re trying to do.

However, I would be personally inclined to approach the problem like this:

  • Create a separate item for each switch channel

  • Create a rule which monitors a state transition from “OFF to ON” for any of those items, and have that rule set all three items to ON. ie

    rule "Turn the lights on"
    when
        Item ShellySwitch1 changed from OFF to ON or
            Item ShellySwitch2 changed from OFF to ON or
            Item ShellySwitch3 changed from OFF to ON
    then
        ShellySwitch1.sendCommand(ON)
        ShellySwitch2.sendCommand(ON)
        ShellySwitch3.sendCommand(ON)
    end
    
  • Do a similar rule for off

The rule will recurse two extra times, causing an additional 2 ON commands to be sent, but that should be relatively harmless.

Someone else may have a much better idea on how to do this. And, like I said, I may not understand what you’re actually trying to do.

So basically these three switches represent different levels - switch1 (“General”) is for all lights in the house, switch2 (“Area 7”) for one area and switch3 (“OG AO Shelly A/PL”) only for the power plug in question.

Therefore I cannot if switch3 is switched ON send an ON command to switch1, because that would switch on all the lights in the house.

I think the problem I have is that if a switch is OFF and receives another OFF, it does not send this OFF on to the channels that follow it. Switch1 and switch2 (general/area) are usually only used for OFF not for ON. But even if they are OFF and receive another OFF, they should send the OFF the the channels that follow it, because those might be ON.

Probably this can be done with a rule triggered by status update instead of status change, but I would be interested to know if there is a way to solve this in the model without having to create rules.

So your first statements did not give all requiremenrs.
The shelly is directly swichting the outlet, the other items are for different groups of items in different levels.
IMHO you should not mix them.up!
Each outlet should have a SINGLE linked item that does the switching of the outlet.
GroupItems can be created to send commands to all members.
Groups can have groups as members.

Your “OG AO Shelly A/PL” would be the single item, “Aera 7” a group containing amongst others the above item and “General” would be a group containing “Area 7” amongst others.

Unless your “Area 7” is actually “Area51”. In that case no human being can say what happens there.

Hi Jürgen,

Thanks for your response and help!

OK, then maybe I need to go back to the basics. For the outlet I have two “things”. One is representing the Shelly plug, the other the switch in the BTicino system. In openHAB I created a single item for the Shelly plug and linked the BTicino channel with default profile, and the power channel of the Shelly plug as follow.

This works as long as I switch only from BTicino. If I also switch it from the Shelly app, this does not work, because the status does not get updated, since the Shelly power is only in follow profile.

So, what would be the correct way to model this, so that the Shelly plug can be switched from both the Shelly world and the BTicino world?

To be honest, I am not sure I understand how to do that. I can setup groups like you say, but how would I associate the group switch with the group? And how would I set it up that the group passes the ON/OFF command to its members?

A copy from the documentation:
“Groups do not only aggregate information from individual member Items, they can also accept commands. Sending a command to a Group causes the command to be sent to all Group members. An example of this is shown by the second group above; sending a single ON or OFF command to that group turns all lights in the group on or off.”

Look here

Thanks, I understand now a bit better how to use groups to model what I want.

What I still cannot solve: if I have a switch that should switch on/off all members of a group, how can I model that? It seems I cannot directly associate the thing/channel or the item representing the switch with the group. Do I need a rule that sends a command to the group when the switch changes?

Never done such via UI myself. So besides the way to configure such a group-item via a things file it should be possible to reconfigure a UI created group-item by selecting “Members Base Settings” via the “Group Settings” to " Switch". See attached picture.

ŕ

That switch should be the item of type group to which the other are connected.

1 Like

Thanks, yes, that works!