Hi,
i have a sonoff rf bridge binded to my openhab system, and i created a rule, that if the following rf button code came across a shelly switch will be turned on.
Here is my code which works for me.
import org.openhab.core.library.types.*
rule "RF"
when
Item RFButton_ changed
then
if (RFButton_.state == NULL)
{
logInfo("rfbutton.rules", "Item is null, cancelling...")
return;
}
var rfData = transform("JSONPATH", "$.RfReceived.Data", RFButton_.state.toString)
logInfo("rfbutton.rules", "Received IT Codes: " + rfData)
switch (rfData) {
case "28E3F2":
Shelly1500291f0483f192168070Buero_Relay_Betrieb.sendCommand(ON)
}
RFButton_.postUpdate(rfData)
end
My Question now is, how can i extend my script, that if i hit the same button again, the switch will be turned off and vise versa. So i am struggling around with the combination of if/else and case.
Can someone help me out ?