Ubiquiti Unifi Binding Feature Discussion

Use a Switch

Here are my items:

/* Unifi Items */

Switch		S8_PRES	"S8 Presence [MAP(Unifi.map):%s]"	<switch>		(gUnifi)	{channel="unifi:client:Unifi_HomeR:S8:online"}
String		S8_AP	"S8 AP [%s]"				<qualityofservice>	(gUnifi)	{channel="unifi:client:Unifi_HomeR:S8:ap"}
Number		S8_RSSI	"S8 RSSI [%s]"				<qualityofservice>	(gUnifi)	{channel="unifi:client:Unifi_HomeR:S8:rssi"}
Number		S8_UPTM	"S8 Uptime [%d]"			<time>			(gUnifi)	{channel="unifi:client:Unifi_HomeR:S8:uptime"}
String		S8_UPTF	"S8 Uptime F [%s]"			<time>			(gUnifi)
DateTime	S8_TIME	"S8 Last Seen [%1$tH:%1$tM:%1$tS]"	<time>			(gUnifi)	{channel="unifi:client:Unifi_HomeR:S8:lastSeen"}

Unifi.map:

ON=Home
OFF=Away
NULL=Unknown

nice trick to display properly the uptime:

Unifi.rules

rule "Format S8 Uptime Display"
when
	Item S8_UPTM changed
then	
	var int days = ((S8_UPTM.state as DecimalType).intValue / (86400))
	var int hours = (((S8_UPTM.state as DecimalType).intValue / 3600) - (24 * days))
	var int minutes = (((S8_UPTM.state as DecimalType).intValue / 60) - ((1440 * days) + (60 * hours)))
	var int seconds = (((S8_UPTM.state as DecimalType).intValue) - ((86400 * days) + (3600 * hours) + (60 * minutes)))
	var String result = ""
	if (days > 0) { result = result + days + "d, " }
	if (hours > 0) { result = result + hours + "h, " }
	if (minutes > 0) { result = result + minutes + "m, " }
	if (seconds > 0) { result = result + seconds + "s" }		
	S8_UPTF.postUpdate(result)
end

then put the formatted item (S8_UPTF) on your sitemap

1 Like