I am still trying to build the perfect light-switch. Thanks @mcullmann (post 180 above).
Let me summarize:
Comfort-Switch B003 switches Q7 permanently, if pulse us longer than 500ms. A short pulse switches-on Q7 only for 20s. B033 to assure that pulse from NI1 is longer than 500m (e.g. 600ms)
Sitemap
sitemap default label="Home" {
Frame label="Light Switch" icon="attic" {
Default item=FF_Dining_Light label="Light (switch here)"
Text item=Logo7_Q7 label="Debug Q7"
Default item=Logo7_NI1 label="Debug NI1 (do not touch)"
}
}
Things
Bridge plclogo:device:Logo7 "Logo7 PLC" [ address="192.168.xxx.yyy", family="0BA7", localTSAP="0x0200", remoteTSAP="0x0200", refresh=1000 ]
{
Thing digital Inputs "Logo7 Inputs" [ kind="I" ]
Thing digital Outputs "Logo7 Outputs" [ kind="Q" ]
Thing pulse VB100_0 "Logo7 NI1" [ block="VB100.0", observe="VB100.0", pulse=200 ]
}
Items
Switch Logo7_Q7 "Licht Essen [%s]" <light> { channel="plclogo:digital:Logo7:Outputs:Q7" }
Switch Logo7_NI1 "NI1" { channel="plclogo:pulse:Logo7:VB100_0:state" }
// virtual Switch
Switch FF_Dining_Light "Licht" <light> (FF_Dining, gLight)
Rules
rule "Switch Light through Logo"
when
Item Logo7_Q7 changed or // 1. light changed external
Item FF_Dining_Light received command // 2. light changed internal
then
if(receivedCommand==ON || receivedCommand==OFF) { // ensure there was a received command, so second item triggered rule
if (Logo7_Q7.state != receivedCommand) { // only if state changed
Logo7_NI1.sendCommand(ON) // send an ON
Logo7_NI1.sendCommand(OFF) // send an OFF ?? Is that really necessary ??
}
}
else { // no trigger from proxy switch, so state changed externally
if (Logo7_Q7.state != FF_Dining_Light.state) { // if state changed really
FF_Dining_Light.postUpdate(Logo7_Q7.state) // update the state without triggering the rule
}
}
end
This seems a bit shaky when toggling Light switch, esp. when toggling fast (status hicks up). Also it does not read the initial state (if logo-light was already on, and then starting up openHAB).
Can we find a simpler solution for light-switching, e.g. without rules?