[SOLVED] Logging from rules prints format codes, not formatted values

Yes there’s a few issues. Hopefully I can nail them down quickly. I have a couple of other rules that could use this treatment as well.

If you use zwave, there were big changes at 2.4 that required all Things to be deleted and rediscovered. There’s a post around here about it. And if you use what was called JSR223 (now scripted automation), there were a number of changes in the API.

1 Like

I was getting this error,

'unit' is not a member of 'org.eclipse.smarthome.core.types.State';

So I used what you’d provided in the previous example you gave, which worked just fine.

rule "Family Room Temperature Check"
when
    Item Sensor_FF_FR_Temperature changed
then
    if (newState != NULL && previousState != NULL) {
        logInfo("DefaultRules",
                "Temperature changed from {} {} to {} {}",
                previousState.format("%.0f"),
                (previousState as QuantityType<Temperature>).unit,
                newState.format("%.0f"),
                (newState as QuantityType<Temperature>).unit
            )
        if (19|°C <= previousState && previousState <= 22|°C) {
            if (newState < 19|°C) {
                loginfo("DefaultRules", "Alarm: Family Room temperature too low")
                sendMail("chris@mydomain.net", "Temperature Alarm",
                        "Temperature in Living Room is below threshold")
            } else if (newState > 22|°C) {
                loginfo("DefaultRules", "Alarm: Family Room temperature too high")
            }
        }
    }
end
~