[SOLVED] Help with a Rule with 2 inputs (AND)

Hi

I have 2 bedroom side lights powered from Sonoff Basics and controlled by their own RF light switches and a Main switch Sonof T1) in the entrance to the room that uses a rule to turn the sidelights on at the same time.

Because the side lights can be turned off independently after they are BOTH turned on from the main entrance switch i am looking for rule that will report back to the main switch once both side lights are off.

All Sonoff items are running Tasmota and are set up already communicating to the MQTT server

Any pointers?

Thanks

Restructure your requirement - a rule that runs when either side light is switched off, then checks to see if both are now off.

What would this look like?

An example would be awesome, been trying for a couple of days with this

Thanks.

What RF technology are you using?

Sonoff bridge with some RF Light switches, that switches sonoff basic

What RF for these? 433MHz?

Yes

These RF light switches are receivers only. They cannot feed back their state to the RF bridge and therefore to openHAB.
Unless you find a way to feed back to openHAB the actual state of the light switches, your requirement cannot be met.
Unfortunately, 433MHz tech is very limited. I suggest that you get two more sonoffs for your bedside lamps

I think you miss understand, the Bedside Lights are switched on and off with a Sonoff basic on each light. These are controlled via the RF Control switch via the sonoff bridge.

LIGHT <> SONOFF BASIC <> OPENHAB <> SONOFF BRIDGE < RF SWITCH

No I don’t
I asked you what RF technology you used for the lights and you said 433Mhz. So I answered accordingly.
How are the two sonoffs configured? Are you using them with the original firware or have you flashed them with something like tasmota?

To put it another way, have you got openHAB Items already configured that reflect the actual state of the side lights?

Making a rule that triggers from either Item changing to OFF is not tricky.

Yes, All items are configured with tasmota and running via the MQTT server.

This is the bit i am struggling with. I want to set up a rule that triggers when BOTH are off though. I can work out the singe trigger easy, i am trying to work out how create on that is for example:

“IF L/H Side light AND R.H Side Light is off THEN Send command OFF to Main Light Switch”

So the main switch is reflecting the state of the side lights

Thanks

rule "Both switches off"
when
    item Right_Switch changed or
    item Left_Switch changed
then
    if (Right_Switch.state == OFF && Left_Switch.state == OFF) {
        Main_Switch.sendCommand(OFF)
    }
end
1 Like

Would putting the two items into a switch group with (on, off) not be simpler? The main switch is then plumbed to the group.

Awesome It was the && i was missing,

Thanks

Please tick the solution, thanks

The outbound state mqtt doesn’t work on a group item…
But you are right the two lights should be in a group
Let’s say:

Group:Switch:AND(OFF, ON) gBedsideLights

Rule:

rule "Both Lights OFF"
when
    item gBedsideLights changed
then
    Main_Switch.sendCommand(gBedsideLights.state)
end

You can’t. OH rules are triggered by events. This was why I suggested rethinking. (The suggestions don’t do that either.)

When you think about, it would be a bit useless anyway - the rule would run all the time both are OFF.

If you want to compare steady states, you can of course do that within a rule. So when should the rule be run? When any of the states you are interested in changes.

It’s just a case of getting your head around the event-driven system to grasp rule triggering, it’ll come :slight_smile:

i needed ‘Item’ before the Right_Switch changed or
Left_Switch changed.

All working now though thanks