Ubiquiti Unifi Binding Feature Discussion

Would you like to see a channel for each?

  • uptimeSeconds : Number
  • uptimeMinutes : Number
  • uptimeHours : Number
  • uptimeDays : Number

If so, questionā€¦

What is the value of uptimeSeconds when uptime = 61?

Logic would say thisā€¦

uptime = 61
uptimeSeconds = 1
uptimeMinutes = 1

What about a fast & dirty String Channel Type where you just dump a pre-formatted text ? :slight_smile:

Same principalā€¦

uptimeString or something similar :smiley:

I would say: 1m 1s

(similar method like the rule does it)

What should the channel be?

If you are going to keep the existing unifi:client:home:matthewsPhone:uptime Channel as a Number (and maybe add UoM support and switch it to: Number:Time :stuck_out_tongue: and Number:Dimensionless for the rssi)
I would say:

unifi:client:home:matthewsPhone:uptimeDuration as a String Type

butā€¦ why keep the Number one? better change the existing Channel type to String and keep the same UID: unifi:client:home:matthewsPhone:uptime

edit: I donā€™t know if using UoM and keeping using Number:Time will be useful to format in the Item label the seconds into other formatsā€¦ I am not using UoM so much to say if this is possible.

@vzorglub : Do you know if I have a Number:Time Channel Type with values in seconds and an Item linked to it: Can I use formatting in the label to display hh:mm:ss ?

The state of the Item would be: 23454 (seconds) and I would like to display this in another wayā€¦ is this possible with UoM? (or the Channel needs to be a DateTime type?)

Relevant for UoM: KNX Binding, Sitemap: Number Item is not send to bus

2 Likes

I havenā€™t used the Time unit yet
Should be possible

1 Like

Didnā€™t even know about UoM :thinking:

After reading that page, I donā€™t think itā€™ll convert how youā€™re thinkingā€¦

Letā€™s say uptime = 3661 (1 hour + 1 minute + 1 second), I think youā€™d get the following:

Number:Time uptimeSeconds "Uptime [%d s]"     => 3661 (1 hour + 1 minute + 1 second)
Number:Time uptimeMinutes "Uptime [%d min]"   => 61   (1 hour + 1 minute)
Number:Time uptimeHours   "Uptime [%d h]"     => 1
Number:Time uptimeDays    "Uptime [%d d]"     => 0
Number:Time uptimeWeeks   "Uptime [%d week]"  => 0

Meaning the conversions wouldnā€™t be dependent on one anotherā€¦ ā€œonly show 1 second because itā€™s the remainder of 1 = 3661 - 3600 (1 hour) - 60 (1 minute)ā€

I think itā€™s a lot easier to trigger a rule based on ā€œsecondsā€ changing to 301 or something like that vs. a string that says ā€œ5m 1sā€ like itā€™s shown in the controller UI. Your format string is simply a visual representation of the raw value seconds.

2 Likes

I am in the process of adding UoM support to my (sensebox), and I have to say, it is pretty easy :slight_smile:

Just look at all the PRs implementing UoM, in most cases it is two lines in the META-INF file and a bit of tweaking in the channels definitions.

1 Like

I also would argue in favor of keeping the uptime channel as a raw number. Channels can be created for the other representations.

IMHO, if the 2.4 release is just a couple weeks away, wouldnā€™t it make sense to keep changes to a minimum and focus on getting the binding into the build.

1 Like

Honestly I had no idea when 2.4 was scheduledā€¦

I will do my best to get it ready, but I wouldnā€™t hold my breath the PR will get approved before 2.4

UoM was fairly easy to implement but the conversions are wrong:

8 h = 60 x 60 x 8 = 28800
28013 < 28800

Yet the internal UoM conversion is showing 8 hoursā€¦

44

I think itā€™s because of the decimal conversion format [%d h]. I would think it would round downā€¦ with time conversions, but it seems to be doing bankers rounding.

Using [%.1f h] gives the partial valuesā€¦

25

Anyways, Iā€™ll look at rebasing asap and re-igniting the PR.

1 Like

Correct!
@mgbowman I would forget about my requestā€¦ itā€™s superficial anyway since we can do the same with the rule!

ETA: 17/Dec/18 openHAB Milestone builds - #140 by Kai

Itā€™s very short timeā€¦

48 hours later: all is good

OH 2.4.0.S1451
Unifi Controller v5.6.40 (not the latest due to EoL of AP-AC Outdoor)
org.openhab.binding.unifi 2.3.0.201812040910

So I made a lot of progress on the PR but some critical parts of the binding changed so PLEASE PLEASE PLEASE update and test the latest build out ASAP so we can try and get this merged!

org.openhab.binding.unifi-2.4.0-SNAPSHOT.jar

YOU HAVE TO UPDATE YOUR CONFIGS AGAIN (sorry)

In preparation for wired client support, the thing ID has changed to wirelessClient (instead of client)

See the Full Example of the README

GO GO GO ā€¦ TEST TEST TEST :smiley:

1 Like

Just updated my two sites. Looks good so far.

1 Like

:+1: :clap: :checkered_flag:

OH 2.4.0 S1451
Unifi Controller v5.6.40
org.openhab.binding.unifi 2.4.0.201812061741

Had to clear tmp&cache and all look good now

Without clearing tmp&cache you get:

2 small warnings because OH2 still tries to load the old (2.3.x) version of the binding
2018-12-06 21:18:12.692 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.unifi-2.4.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [254]
  Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.3.0.201812040910"; osgi.identity="org.openhab.binding.unifi"; singleton:="true"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [10:org.apache.felix.fileinstall:3.6.4]
2018-12-06 21:18:12.703 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.unifi-2.4.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [254]
  Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.3.0.201812040910"; osgi.identity="org.openhab.binding.unifi"; singleton:="true"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [10:org.apache.felix.fileinstall:3.6.4]

Hmm. I didnā€™t see this. Maybe because I removed the 2.3 version of the binding from addons before adding the 2.4 version?

I did the same:
stop OH2
remove old 2.3 *.jar from addons, wget new 2.4 *.jar
start OH2

maybe there were some leftovers in tmp&cacheā€¦ I didnā€™t really checkā€¦ I just went ahead and wiped them both

Ok. I didnā€™t stop/start OH. Just deleted 2.3 binding, then added 2.4.

1 Like