Hi,
How can I turn these 2 rules I used in OH2 to become full main ui rules (so they can be edited through the ui)?
With the first of these rules I am unsure how to integrate them via the main ui because of the use of timers:
Rule 1:
var Timer pfortentimer3s = null
var Timer pfortentimer5s = null
rule "Pfortentimer3s"
when
Item Pfortenoeffner received command 3
then
if (pfortentimer3s === null)
{
PfortenFfner_1_State.sendCommand(ON)
pfortentimer3s = createTimer(now.plusSeconds(3)) [|
pfortentimer3s.cancel()
pfortentimer3s = null
PfortenFfner_1_State.sendCommand(OFF)
]
}
end
rule "Pfortentimer5s"
when
Item Pfortenoeffner received command 5
then
if (pfortentimer5s === null)
{
PfortenFfner_1_State.sendCommand(ON)
pfortentimer5s = createTimer(now.plusSeconds(5)) [|
pfortentimer5s.cancel()
pfortentimer5s = null
PfortenFfner_1_State.sendCommand(OFF)
]
}
end
With the second one I am unsure on how to tto the switch cases within the main ui and would be grateful for guidance.
Rule 2:
rule "Xiaomi Switch - LivingRoom"
when
Item XiaomiSwitchLivingRoom_click received update
then
switch(XiaomiSwitchLivingRoom_click.state.toString) {
case "single": {
if(LivingRoomLight.state != 0 && (LivingRoomLight.state > 43 || LivingRoomLight.state < 41)) {
LivingRoomLight.sendCommand(OFF)
}
else {
LivingRoomLight.sendCommand(6)
}
}
case "double": {
if(LivingRoomLight.state != 0 && (LivingRoomLight.state > 7 || LivingRoomLight.state < 5)) {
LivingRoomLight.sendCommand(OFF)
}
else {
LivingRoomLight.sendCommand(42)
}
}
case "triple": {
Pfortenoeffner.sendCommand(3)
}
case "quadruple": {
}
case "many": {
}
case "long": {
Pfortenoeffner.sendCommand(3)
}
case "long_release": {
}
}
end