This is a wiki article and can be improved by everyone. Please do!
Problem Statement
How to switch a Logo-output for lights or power outlets via openHAB and in parallel via a physical wall-switch which is directly connected to a Logo-input? The status of the Logo-output shall be correctly monitored.
Concept
A proxy-item is used for the UI to store the on/off state (for visualisation) and for user-interaction. UI-commands are sent to the NI-item (pulse) which toggles the Logo’s relay (Q-output). Events originating from Logo (physical wall-switch pressed causing relay changes) will update the proxy-item by the rule. A rule triggered once at openHAB startup initializes the proxi-item and writes the current relay status into it.
Solution
Here is a screenshot of what the result looks like.
LOGO! Configuration (LOGO! SoftComfort Diagram Editor)
Things (logo7.things)
In this example, the IP address 192.168.xxx.yyy represents the Logo device’s address and must be adapted.The TSAP parameters must be adjusted as well.
Bridge plclogo:device:Logo7 "Logo7 PLC" [ address="192.168.xxx.yyy", family="0BA7", localTSAP="0x0200", remoteTSAP="0x0200", refresh=1000 ]
{
Thing digital Outputs [ kind="Q" ]
Thing pulse VB100_1 "Logo7 NI4" [ block="VB100.1", observe="VB100.1", pulse=200 ]
}
Items (logo7.items)
Switch Logo7_Q12 "Licht Wand [%s]" <light> { channel="plclogo:digital:Logo7:Outputs:Q12" }
Switch Logo7_NI4 "NI4" { channel="plclogo:pulse:Logo7:VB100_1:state" }
Switch Wall_Light_proxy "Light Wall" <light> (Wall_proxy, gLight)
Rules (logo7.rules)
rule "Switch Light Wall Logo"
when
Item Logo7_Q12 changed or // light changed external
Item Wall_Light_proxy received command // light changed internal
then
if(receivedCommand==ON || receivedCommand==OFF) { // ensure there was a received command, so second item triggered rule
if (Logo7_Q12.state != receivedCommand) { // only if state changed
Logo7_NI4.sendCommand(ON) // send a pulse
}
}
else { // no trigger from proxy switch, so state changed externally
if (Logo7_Q12.state != Wall_Light_proxy.state) { // if state changed really
Wall_Light_proxy.postUpdate(Logo7_Q12.state) // update the state without triggering the rule
}
}
end
rule "Startup"
when
System started
then
// logInfo("StartUp", "System startup: Logo states flushed into proxy switches")
Wall_Light_proxy.postUpdate(Logo7_Q12.state) // update the state at startup
end
Sitemap (default.sitemap)
sitemap default label="Home" {
Frame label="Light Switch" icon="attic" {
Switch item=Wall_Light_proxy mappings=[OFF="AUS", ON="EIN"]
Switch item=Logo7_NI4 label="Debug NI4 (do not touch)" // remove this line
}
}
Revision History
- Janaury 2019: original post for openHAB version 2.4 with Logo 0BA7
- February 2019: completely re-edited, this works nicely.
Troubleshooting
- none
Next Ideas
- none