I used your rule and changed it to my Items.
Rule:
rule "format uptime"
when
Time cron "32 0/5 * * * ?"
then
var int days = (Sys_OH2_Uptime.state as DecimalType).intValue / (24 * 60)
var int hours = ((Sys_OH2_Uptime.state as DecimalType).intValue / 60) - (24 * days)
var int minutes = ((Sys_OH2_Uptime.state as DecimalType).intValue - 60 * (24 * days + hours))
var String result = ""
// days
if (days > 0) {
result = result + days + " Tage / "
}
// hours
if (hours > 0) {
result = result + hours + " Std. / "
}
// minutes
if (minutes > 0) {
result = result + minutes + " Min."
} Sys_OH2_UptimeFormatted.postUpdate(result)
logInfo("system.rules", "Uptime updated to " + Sys_OH2_UptimeFormatted.state)
end
My Items:
Number Sys_OH2_Uptime "Uptime [%s]" (gSys) { channel="systeminfo:computer:openhab2:cpu#uptime" }
Number Sys_OH2_UptimeFormatted "Uptime Formatted [%d]" (gSys)
But I get an error in the logs:
2018-11-11 11:00:32.124 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '7 Std. / 59 Min.' to a state type which item 'Sys_OH2_UptimeFormatted' accepts: [DecimalType, QuantityType, UnDefType].
2018-11-11 11:00:32.134 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to NULL
2018-11-11 11:05:32.099 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '8 Std. / 4 Min.' to a state type which item 'Sys_OH2_UptimeFormatted' accepts: [DecimalType, QuantityType, UnDefType].
2018-11-11 11:05:32.106 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to NULL
2018-11-11 11:10:32.138 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '8 Std. / 9 Min.' to a state type which item 'Sys_OH2_UptimeFormatted' accepts: [DecimalType, QuantityType, UnDefType].
2018-11-11 11:10:32.146 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to NULL
I tried the script from @rtvb (thanks), that works for basicUI, but not for PaparUI. Is there anything changed in the past two years regarding transformation within an item label?
upper part = paperui, lower part is basicui:
Thanks, too bad. Administrator interface or not, i think it should have the transformation in place, for testing purpose etc. Anyway, with the all new UI that is being developed for 3.0 i don’t think anyone should waste their time implementing it for paperui
it works for me as well but I do not like so many logs to be pushed.
In your example @pbogocz you run the rule every 5min and 32sec. do you observe so many logs as rule launch?
2020-04-15 14:15:44.036 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:45.036 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:46.034 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:47.038 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:48.033 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:49.037 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:50.019 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:51.037 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:52.015 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:53.017 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:54.016 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 27 Min.
2020-04-15 14:15:54.202 [vent.ItemStateChangedEvent] - RaspberryPiUptime changed from 27.3 to 28.3
2020-04-15 14:15:55.036 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 28 Min.
2020-04-15 14:15:55.037 [vent.ItemStateChangedEvent] - RaspberryPiUptimeFormatted changed from 27 Min. to 28 Min.
2020-04-15 14:15:56.015 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 28 Min.
2020-04-15 14:15:57.037 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 28 Min.
2020-04-15 14:15:58.015 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 28 Min.
2020-04-15 14:15:59.018 [INFO ] [.smarthome.model.script.system.rules] - Uptime updated to 28 Min..
It seems info log are being pushed until 1min overclock. every sec. or less.
Does it mean the script and the maths are being done with the same frequency ot it is being done one. It is strange and not efficient, unless I am wrong.