Electric Car - Need help creating rules based on logs

Thanks!!

one last question, as e.g. after changing config files the item will go to “NULL” m rules run (i guess) into a problem. What is the smartest way to overcome this…i already did a rule on systemstart…but this seems to not trigger when e.g. only config files change. would it make sense to change it that way…so if it is NULL when charging starts…it would immediately go to ON and from there its no problem again ???

// ***************************************************************************************************
    rule "ChargeStart Detection"
    when
        Item EVchargePower received update
    then
        if ((EVchargePower.state > 1000) && (Car_Charging.state == OFF) || (Car_Charging.state == NULL)
               { Car_Charging.sendCommand(ON)
                 EVchargeStartMeter.postUpdate(EVchargeWhImp.state)
               }
    end

Yes. They’ll do the same at system boot time, unless you persist and restore them, or unless the binding is able to populate them before your rules run.

It’s not demanding to structure your rules not to use invalid data, and will likely pay dividends in situations you haven’t thought of yet.

if (someItem.state != NULL && otherItem.state != NULL) {
   // woohoo, both states I want to process are valid
} else {
   logInfo("test", "One Item at least is not ready, skipping processing")
}

Note that some bindings can also assign state UNDEF in the event of problems, like a communication failure.

Sometimes just use of != not-equals is powerful

if (someItem.state == OFF) {
   // this won't work for NULL or UNDEF
}

if (someItem.state != ON) {
   // this will work for OFF, NULL or UNDEF i.e. not-ON
}
1 Like