# \[SOLVED\] Format uptime System Info binding

**URL:** <https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049>\
**Category:** Runtime\
**Tags:** transform, systeminfo, duration\
**Created:** [May 28, 2016, 12:56pm UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049 "2016-05-28T12:56:22Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![pbogocz](https://community.openhab.org/letter_avatar_proxy/v4/letter/p/d26b3c/32.png) [@pbogocz](https://community.openhab.org/u/pbogocz)\
**Post date:** [November 11, 2018, 10:14am UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/21 "2018-11-11T10:14:44Z")

</div>

I used your rule and changed it to my Items.  
Rule:

```csv
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:

```csv
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:

```csv
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

```

What is the problem here?  
Any Ideas?

---

<div class="post-metadata">

**Author:** ![pbogocz](https://community.openhab.org/letter_avatar_proxy/v4/letter/p/d26b3c/32.png) [@pbogocz](https://community.openhab.org/u/pbogocz)\
**Post date:** [November 11, 2018, 10:30am UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/22 "2018-11-11T10:30:40Z")

</div>

Ok, got it.  
I changed the item to String and it works!

---

<div class="post-metadata">

**Author:** ![Simon\_Thorsted](https://community.openhab.org/user_avatar/community.openhab.org/simon_thorsted/32/36096_2.png) [@Simon\_Thorsted](https://community.openhab.org/u/Simon_Thorsted)\
**Post date:** [April 11, 2019, 8:50pm UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/23 "2019-04-11T20:50:13Z")

</div>

ok i have the openhab log showing the right uptime in days hours and min in a blue line , but how can i show i on the sitemap ,can anyone help please

---

<div class="post-metadata">

**Author:** ![Peter\_Aschinger](https://community.openhab.org/user_avatar/community.openhab.org/peter_aschinger/32/47554_2.png) [@Peter\_Aschinger](https://community.openhab.org/u/Peter_Aschinger)\
**Post date:** [December 18, 2019, 5:15am UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/24 "2019-12-18T05:15:41Z")

</div>

Hey Robert,  
thank you for this solution. Works perfectly here at my Raspi

---

<div class="post-metadata">

**Author:** ![lsiepel](https://community.openhab.org/user_avatar/community.openhab.org/lsiepel/32/17435_2.png) [@lsiepel](https://community.openhab.org/u/lsiepel)\
**Post date:** [December 30, 2019, 10:06pm UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/25 "2019-12-30T22:06:25Z")

</div>

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:

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/c/ac5ef97c1aa0208dbb0451c1257eb9eee870f2e9.png)

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [December 30, 2019, 10:15pm UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/26 "2019-12-30T22:15:13Z")

</div>

PaperUI is still an administrators interface for system setting up and testing etc., and is not intended to have nice presentation goodies.

---

<div class="post-metadata">

**Author:** ![lsiepel](https://community.openhab.org/user_avatar/community.openhab.org/lsiepel/32/17435_2.png) [@lsiepel](https://community.openhab.org/u/lsiepel)\
**Post date:** [December 30, 2019, 10:33pm UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/27 "2019-12-30T22:33:47Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![wiewior](https://community.openhab.org/letter_avatar_proxy/v4/letter/w/2acd7d/32.png) [@wiewior](https://community.openhab.org/u/wiewior)\
**Post date:** [April 15, 2020, 12:43pm UTC](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049/28 "2020-04-15T12:43:03Z")

</div>

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?

```csv
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.

[Previous page](https://community.openhab.org/t/solved-format-uptime-system-info-binding/11049.md?page=1)
