Ubiquiti Unifi Binding Feature Discussion

What @martinvw says. If you later on need one of those values of specific reasons it’s not helpful to have them in one parameter.

1 Like

I agree with the parameters needing to have a dedicated meaning but both optional?

If they’re both optional, I could set a CONFIGURATION_ERROR status with a detail saying at least one of the mac or hostname parameters needs to be defined.

2 Likes

Hi there!
I’m kind of new to Openhab specially compared with you guys!
In the search of better presence detection than the one I’ve got i came across this thread and the Unifi binding. I do got a UAP and a Unifi controller running on a Raspberry but I can’t figure out how this binding is installed, is there any chance anyone can point me in the right direction and maybe give me some hints if necessary?
Thank you!
/c

Download the jar file from here, and then put it in your openHAB addons directory.

Then in Paper UI,

Configure Controller Thing

  • click on the little blue + icon,
  • select Unifi Binding, then
  • select Unifi Controller
  • configure the Controller using your specific settings

Configure Client Thing

  • click on the little blue + icon again,

  • select Unifi Binding, then

  • select Unifi Client

  • configure the Client using your specific settings

  • Repeat the Client Thing step for additional clients.

Post back here with any questions.

Hi Matthew,

very strange: I resaved my items file - Items were refreshed and the errors didn’t re-appear again.
I’ll try to re-produce the error and pull more logs as you suggested.

Kurt

I added client name support so now you can define the client by the MAC address or the name. The name is as it’s seen by the controller - either the hostname or the alias that you can define via the configuration tab in the clients view of the controller.

Please test it out and let me know if you have any issues.

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

IMO having two “unique” identifier properties that are optional is redundant and could potentially confuse users. Since we have an edge-case where using the MAC address won’t work, I would prefer to just use the name of the client and make it required and just do away with the MAC address altogether.

Thoughts?

1 Like

I like hostnames, FQDNs and (especially) aliases much better than MACs. I am with you on this one :slight_smile:

1 Like

Same here. Easier than dealing with MAC addresses.

Thank you mhilbush! I got it working, really nice binding. Suits my needs perfectly.

1 Like

I prefer having both but at least the mac address. When having multiple sites the mac address is always the same and detection always works. When only having hostnames it would mean in my case making sure that all mobile equipment is named exactly the same on 15 sites…

There may be another issue with hostnames: Not all devices register a hostname on the Unifi Controller (I am on 5.6.40)
In this case: Their hostname will display the MAC in the Name field of the Clients table.
You can set an Alias of course to overcome this.

Your 15 site setup is also an edge-case but I understand the pain of setting the same Aliases in all 15 sites :slight_smile:

Thanks for the URL and step-by-step instructions.Works perfectly! And many thanks @mgbowman for a great binding! Keep up the good work :slight_smile:

Can you enable TRACE logging and send me a PM with the JSON output of a client only showing the MAC as the name?

This brings me back to the idea of using names and you can always put in the MAC address as a “catch-all” for these edge cases.

I still think we should only have one unique identifier that’s a required config parameter.

sure

want me to TRACE the one that I am currently running (v10 = 2.3.0.201804221805 org.openhab.binding.unifi) or the latest ? (v14 = Ubiquiti Unifi Binding Feature Discussion)

Either build… I want to see what the controller is spitting out in these cases.

This is a WLAN connected Samsung TV:

    {
      "_id": "5aee8e91e4b0ba053476594e",
      "duration": 5827653,
      "first_seen": 1525583505,
      "is_guest": false,
      "is_wired": false,
      "last_seen": 1541892597,
      "mac": "50:85:69:8e:83:70",
      "name": "",
      "noted": false,
      "oui": "SamsungE",
      "rx_bytes": 24487358609,
      "rx_packets": 135462296,
      "site_id": "5aee8764e4b0ba05347658bd",
      "tx_bytes": 102751470500,
      "tx_packets": 176587811,
      "usergroup_id": ""
    },

it does not broadcast a hostname, so in Unifi Controller it appears as:

image

If I set an Alias in the properties of the client, I get a name reported in the json:

    {
      "_id": "5aee8e91e4b0ba053476594e",
      "duration": 5827653,
      "first_seen": 1525583505,
      "is_guest": false,
      "is_wired": false,
      "last_seen": 1541892597,
      "mac": "50:85:69:8e:83:70",
      "name": "Samsung TV",
      "noted": true,
      "oui": "SamsungE",
      "rx_bytes": 24487358609,
      "rx_packets": 135462296,
      "site_id": "5aee8764e4b0ba05347658bd",
      "tx_bytes": 102751470500,
      "tx_packets": 176587811,
      "usergroup_id": ""
    },

the hostname is not reported (even with an alias)

Yep we have another edge case :stuck_out_tongue_winking_eye:

So in these cases I think just using the MAC address in the name field would be an acceptable solution to me as the controller has named the client by MAC.

For me, the cleanest solution is to just have an ID parameter that accepts MAC, hostnames or aliases. This covers all edge cases and keeps the config straight forward: you have one required parameter that accepts 1 of 3 possible values.

unfortunately, in this case where the hostname is “not existing”, the Unifi Controller doesn’t populate the "name" json field with the MAC Address :frowning: (it leaves it blank). It does show the MAC as the “Name” on the web interface but does not report it either as a hostname or a name (in the json).

You would need to manually set an Alias (using the MAC or any other name) to get the "name" field to get populated.

:+1:

If we do it as just one parameter, it won’t matter how the controller reports it. I index it by all 3 parameters returned by the controller (assuming non-null): mac, hostname and name.

So regardless of which value you define on the client’s ID, the binding should find it.

2 Likes