Design question: searching for things (getThingByUID) [message #1768281] |
Sun, 16 July 2017 16:20  |
Eclipse User |
|
|
|
Hallo,
In the new binding I am writing for OH2, devices are identified as:
mybinding:deviceType:bridgeID:deviceID
where deviceID is the unique ID used to identify devices in the network protocol I am integrating, while deviceType is set during Thing discovery phase.
Then when a new device event arrives from the network protocol I need to associate the event to the Thing/ThingHandler, so I need to use getThingByUID() in the bridge handler.
However, I cannot search for the Thing as the network protocol event does not bring any info on the device type, only the deviceID.
So I cannot associate network protocol events coming from a specific deviceID with the corresponding Thing in ESH.
What is the right design approach to be used?
OPTIONS:
1) I could avoid using deviceType in the ThingUID:
mybinding:bridgeID:deviceID
but this way the UI/user will miss the info that this device is of that specific deviceType.
2) Another option would be to have a more flexible method getThingByUID capable of finding Things also with "*" search, for example:
getThingByUID("mybinding:*:bridgeID:deviceID")
to find the Thing with ID=deviceID, regardless of its specific type.
Any other suggestion?
Thanks a lot,
Massi
|
|
|
|
|
|
Re: Design question: searching for things (getThingByUID) [message #1773804 is a reply to message #1768512] |
Wed, 04 October 2017 16:07  |
Eclipse User |
|
|
|
Thanks Stefan, I implemented the suggested behaviour and it works.
While I was coding, I was thinking that since this "deviceID -> thing handler" mapping is possibly common to many bindings, it should be already supported by the ESH core.
In addition I see that there is a 'representation-property' that I probably should use to make sure the same device is not discovered twice.
Is this the expected usage of this type of properties?
thanks
Massi
|
|
|
Powered by
FUDForum. Page generated in 0.07207 seconds