Create the rules to manage the states between “Gate_state” and the Gate_full, Gate_partial and Gate_status
rule "Close Gate"
when
Item Gate_state received command "CLOSED"
then
Gate_full.sendCommand(OFF)
end
rule "Open Gate Fully"
when
Item Gate_state received command "OPEN"
then
Gate_full.sendCommand(ON)
end
rule "Open Gate Partially"
when
Item Gate_state received command "PARTIAL"
then
Gate_partial.sendCommand(ON)
end
rule "Gate changed"
when
Item Gate changed
then
val gateState = Gate.state
if (gateState == OPEN) {
Gate_state.postUpdate("OPEN")
}
if (gateState == CLOSED) {
Gate_state.postUpdate("CLOSED")
}
end
Not sure how you will know if the gate is partially open. What’s the value of Gate_status then? You’ll need to add that to the rule …
So, it partially works. The states arent working right…
The log is FILLED with this,
20:10:29.633 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:29.690 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:29.733 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:29.936 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:29.983 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:30.139 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:30.212 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:32.333 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:32.383 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:32.486 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:32.540 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:35.035 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:35.085 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:35.132 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:35.182 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:40.085 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:40.132 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:41.534 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:41.582 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:41.935 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
20:10:41.988 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from OPEN to CLOSED
20:10:42.035 [INFO ] [smarthome.event.ItemStateChangedEvent] - Gate_status changed from CLOSED to OPEN
rule "Gate Action"
when
Item Gate_state received command
then
if (Gate_state.state.toString == "OPEN") {
Gate_full.sendCommand(ON)
}
if (Gate_state.state.toString == "CLOSED") {
Gate_full.sendCommand(OFF)
}
if (Gate_state.state.toString == "PARTIAL") {
Gate_partial.sendCommand(ON)
}
end
rule "Gate changed"
when
Item Gate changed
then
val gateState = Gate.state.toString
if (gateState == "OPEN") {
Gate_state.postUpdate("OPEN")
}
if (gateState == "CLOSED") {
Gate_state.postUpdate("CLOSED")
}
end
This piece of code displays this like video nicely using a basic UI sitemap, however no matter what I try in HabPanel, it doesnt work correctly on Mobile.
Can you suggest how I can embed this code to work correctly on mobile? It a 640x480 Webcam feed from a doorbell.