Issue of the topic: I need to change the switch state based on contact state
Hello,
I need a little help, please.
My setup:
I use a mcp23017 connected to a 8 channel relay board witch command the lights, but I also use the actual wall switch (3 way). I also use this board to read actual light status.
Items
rule "LivingRoom light status"
when
Item living_room_light_status changed
then
if (living_room_light_status.state == OPEN){
if (living_room_light_switch_A5.state == OFF){
postUpdate(living_room_light_switch_A5, ON)
}
}
if (living_room_light_status.state == CLOSED){
if (living_room_light_switch_A5.state == ON){
postUpdate(living_room_light_switch_A5, OFF)
}
}
end
My problem:
with this setup, if the light is switched ON from the wall switch, then I have to press twice in OH to switch.
Can anyone help me please?
Thank you.
Tell us about this relay board - this is controlling the lights directly, or controlling further relays? Impulse relays?
Which device does the wallswitch control act upon?
Thank you for the quick reply.
Yes, the relay is controlling the lights directly and acting as a 2 way switch together with the wall switch(also 2 way switch).
The “Optocoupler” board is reading the actual status of the light bulb (acting as contact).
I tried to make a schematics.
It works great, but if I switch the light from wall, the OH dose not know, that’s why I use the “Optocupler” board, to read the actual status of the light, but with my rule, when I switch the light from the wall, it changes status, but I have to press twice in OH to execute switch.
Your problem is that an indication of your relay being ON does not mean your light is on - because of your two-way switching.
Equally, commanding your relay ON might result in the light turning on or off, depending on the wall switch position.
I’d abstract this.
Make a proxy Switch Item, this is what to use on your sitemap. You have to use a Switch here, because you cannot send commands to Contact.
A rule like you already have to reflect the actual state of the light into that proxy Item (not the relay control).
Another rule that listens for commands to proxy, and only if the command is not the same state as actual, changes the state of the relay control.
EDIT - I forgot, I would set autoupdate false on the proxy, so it reflected reality not last command.