I’ve been prototyping a new UniFi Binding for OH2 which connects to the UniFi controller and track devices for “presence” detection. One thing I cannot wrap my head around is how to accomplish this using the new OH2 concepts. According to the new opeHAB 2 concepts overview, “Channels can be linked to multiple Items and Items can be linked to multiple Channels.” I don’t quite fully understand how this n to m relationship of Channels and Items is even possible.
I initially thought I would need one instance of the binding per device, which to track multiple devices results in a lot of duplicate config, a lot of redundant network round trips and would create an all around confusing user experience. Yes, this would work, but it feels like I’m trying to use a hammer when what I need is a screwdriver.
Ideally, I should only need one instance of the binding connected to the UniFi controller (the Thing) that could track n devices (the Channels) which would be linked to n (read-only) “presence” Switches (the Items). Where I’m drawing a blank is the fact that each Channel requires a user supplied MAC address which obviously can’t be pre-defined in the thing-types.xml file.
From searching the community, it appears there might be a way to dynamically create channels at runtime. So following that logic, I could create a channel per device that’s discovered and the user would be able to link items to just the devices of interest (assuming simple linking was disabled). Am I heading in the right direction with this?
Thanks in advance!