This code is working well. Also, got that error in log.
rule "ping ArduinoSwitchInverter"
when Item ping_192_168_1_10_online changed
then
if (ping_192_168_1_10_online.state == ON) {
logInfo("Alert:", "ArduinoSwitchInverter changed to ON")
Relay3.sendCommand(Relay3.state.toString)
Relay4.sendCommand(Relay4.state.toString)
}
else logInfo("Alert: ", "ArduinoSwitchInverter changed to OFF")
end
Which only happens because Relay4 is currently NULL, just make sure that the Relay4 item has a valid state, and persist that state and you should never see that error again.
rule "ping ArduinoSwitchInverter"
when Item ping_192_168_1_10_online changed to ON
then
logInfo("Alert:", "ping ArduinoSwitchInverter changed to ON")
if (Relay3.state != UNDEF && Relay3.state != NULL) Relay3.sendCommand(Relay3.state.toString)
if (Relay4.state != UNDEF && Relay4.state != NULL) Relay4.sendCommand(Relay4.state.toString)
end
Thread like this are awesome in how they demonstrate how a Rule can be created and incrementally improved little by little until you get a super concise and simple Rule.
I’m going to add this thread as an example in the DRY DP for an example of how to iterate and refactor Rules.