rule "Button Pressed"
when
Item Sonoff_Button received update // Need received update if Data has not changed but button still pressed
then
Thread::sleep(100) // Need the sleep to allow for the state to change
if (Sonoff_Button.state == "6A8CD2") {
if (S4CH04.state == ON || S4CH04.state == NULL) { S4CH04.sendCommand(OFF) }
else { S4CH04.sendCommand(ON) }
}
end
now the next question… I have one more switch in my rf button, that sends another code… what is best practise then?? make another file rule, similar to this one, and with other data, or can I continue in this rule, with another RF code…?
Yep!
If you have just another one of two buttons then if then will be enough
More than that it will get confusing and use the case switch
rule "Button Pressed"
when
Item Sonoff_Button received update // Need received update if Data has not changed but button still pressed
then
if (Sonoff_Button.state == NULL) return; //Do nothing if NULL
Thread::sleep(100) // Need the sleep to allow for the state to change
if (Sonoff_Button.state == "6A8CD2") {
if (S4CH04.state == ON || S4CH04.state == NULL) { S4CH04.sendCommand(OFF) }
else { S4CH04.sendCommand(ON) }
}
if (Sonoff_Button.state == "6A8CD8") {
if (otherSwitch.state == ON || otherSwitch.state == NULL) { otherSwitch.sendCommand(OFF) }
else { otherSwitch.sendCommand(ON) }
}
end