Ubiquiti Unifi Binding Feature Discussion

The binding works perfectly! :slight_smile:
next part is <offtopic> :stuck_out_tongue:

an alternative to this, is this:

Number		Angelos_S8_UPTM	"Angelos S8 Uptime [JS(duration_from_seconds.js):%s]"	<time>		(gUnifi)	{channel="unifi:wirelessClient:Unifi_HomeR:Angelos_S
8:uptime"}

/etc/openhab2/transform/duration_from_seconds.js (thanx to @Mihai_Badea from here)

// computes nicely formatted duration from given seconds
(function(i){
	var date = new Date(null);
	date.setSeconds(parseInt(i)); // specify value for SECONDS here
	return date.toISOString().substr(11, 8);
})(input)

I don’t know which is more “expensive”… the JS xform or the rule calculations… I would go with JS being better/lighter. No need for a second dummy Item and the state of the original Item keeps the seconds as value. The xform is done only for display purposes.

1 Like