openbase / bco.device

Other
0 stars 0 forks source link

Problems with automatic registration of Philips Hue Motion Sensor #76

Closed pLeminoq closed 3 years ago

pLeminoq commented 4 years ago

The Philips Hue Motion Sensor also has a light sensor, a temperature sensor and a battery. Accordingly the device class has been created. However, instead of providing a single thing with all of these services, the Hue binding provides three different things (this is different from the behavior of the ZWave binding). All of these things share the same model id (the identifier used to map things to device classes). Therefore, our automatic registration will add three devices to BCO and for each only the service which maps to that thing type will work properly.

How should we handle this? Build a special workaround for this device?

DivineThreepwood commented 4 years ago

Build a special workaround for this device?

I would recommend to find a generic solution because there are more hue devices, such as the wireless button, that has the same issue. Could you upload the list of thing properties for each of the three things offered for the motion sensor?

I would recommend the following solution:

  1. Find any property that matches for all three things of the same device -> DEVICE_ID (at least the hue device id should match right?)
  2. The inbox approver should approve all three devices. (This is already the case when the modelid matches)
  3. The openhab device manager should now make sure that once a new device is found but a device already exist with the same DEVICE_ID, than the openhab_items of thing are matched onto the services of the existing bco_device instead of creating a new device.

Could you validate if this approach could work?

jdaberkow commented 4 years ago

@DivineThreepwood What do you mean with "hue device id"? Here is an example of the three things of the same device:

modelId | SML001
productName | Hue ambient light sensor
uniqueId | 00:17:88:01:04:b6:9d:6c-02-0400
vendor | Signify Netherlands B.V.
modelId | SML001
productName | Hue motion sensor
uniqueId | 00:17:88:01:04:b6:9d:6c-02-0406
vendor | Signify Netherlands B.V.
modelId | SML001
productName | Hue temperature sensor
uniqueId | 00:17:88:01:04:b6:9d:6c-02-0402
vendor | Signify Netherlands B.V.
jdaberkow commented 4 years ago

From what I'm seeing, in this case there is no way to determine exactly whether sensors belong together or not. I think only heuristic approaches could be a (somewhat hacky) solution in this case.

jdaberkow commented 4 years ago

Nice to know: Home Assistant also generates 3 devices. But here we would be able to find the three belonging instances more easily, since it gives them the same prefixes in their names. Whereas openHAB unfortunately does not 😥.

EDIT: Home Assistant is even already relating them on its own:

Screenshot 2020-09-09 at 16 18 18
DivineThreepwood commented 4 years ago

@DivineThreepwood What do you mean with "hue device id"? Here is an example of the three things of the same device:

Within the hue bridge each devices has its own device id that is just a number between 1 - 60. OpenHAB still uses this id to map its item channels onto the physical devices. For example, this is the id of a hue bulb color servicehue:0210:001788216d56:46:color where hue defines the binding 0210:001788216d56 defines the bridge id and 46 the device id. However, I am not sure if this id is accessible since its not listed as thing property. Could you compare the uniqueId | 00:17:88:01:04:b6:9d:6c-02-0402 between different devices. Those property seems to be new and maybe it offers useful information to solve the mapping.

jdaberkow commented 4 years ago

I cannot compare the uniqueId, since I only have one device.

However, the deviceId on the Hue Bridge differs as well, as you can see here:

Screenshot 2020-09-09 at 22 25 11
jdaberkow commented 4 years ago

Also the uniqueId wont help us much here. I compared the uniqueIds of two different RGB Hues of the same type. They have the same and thus can be seen more as an alternative to the modelId.

EDIT: Maybe I was too tired yesterday...

pLeminoq commented 4 years ago

In my case the unique id would help, since it really is unique. Furthermore, comparing to your sensor unique ids, they seem to share the initial part of the unique id and always end with 0400, 0402 and 0406. 0400 is always the light sensor, 0402 the temperature sensor and 0406 the motion sensor. I would try to implement a solution using this information, but I still think this is a workaround/hack because we cannot be sure how the unique ids will look for other devices.

Device UniqueId
Light Sensor 00:17:88:01:08:62:df:94-02-0400
Motion Sensor 00:17:88:01:08:62:df:94-02-0406
Hue Temperature Sensor 00:17:88:01:08:62:df:94-02-0402
Hue Color 1 00:17:88:01:10:54:cd:b9-0b
Hue Color 2 00:17:88:01:10:3b:d8:8e-0b
Hue Color 3 00:17:88:01:10:4c:1c:fb-0b
Hue Switch 00:17:88:01:06:eb:3c:83-02-fc00
Hue Filament Bulb 00:17:88:01:08:ec:46:60-0b
Hue Lightstrip 00:17:88:01:04:4b:07:42-0b
Hue White 1 00:17:88:01:06:01:f5:3a-0b
DivineThreepwood commented 3 years ago

After fixing a minor bug :p the device registration is working now and all three devices are merged into one. Therefore, issue is solved :)