Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Sonos: Add Channel for UDN to prevent hardcoding UDNs everywhere #4872

Closed
AfromD opened this issue Jan 7, 2018 · 9 comments
Closed

Sonos: Add Channel for UDN to prevent hardcoding UDNs everywhere #4872

AfromD opened this issue Jan 7, 2018 · 9 comments

Comments

@AfromD
Copy link

AfromD commented Jan 7, 2018

To have cleaner code, I wish it would be possible to have an item containing the UDN of a zone. I would like to code like this:
sendCommand(SonosFernseher_Add, SonosBadezimmer_UDN.state)
This is more legible, and it prevents the hardcoding of strings into my rules, which might make things more complicated than necessary when I change things or items or hardware.
Currently, I help myself by defining empty items and then populating them by hand (hardcoding, but at least only in one central spot):
String SonosBadezimmer_UDN "UDN"

rule "Populate Sonos UDN items" when System started then SonosWohnzimmer_UDN.postUpdate("RINCON_000E5823463A01400") SonosBadezimmer_UDN.postUpdate("RINCON_000E5810648001400") SonosKinderzimmer_UDN.postUpdate("RINCON_000E5850024001400") SonosSchlafzimmerR_UDN.postUpdate("RINCON_5CAAFD080BC801400") SonosSchlafzimmerL_UDN.postUpdate("RINCON_5CAAFD080C0401400") SonosFernseher_UDN.postUpdate("RINCON_000E58B001FC01400") end

It would be nicer and more robust if the binding could provide me with the UDN. Then I don't have to configure that in multiple places (me in the thing definition and rules, other people probably all over the place)

@maggu2810
Copy link
Contributor

Isn't the UDN already present as a thing property?

@AfromD
Copy link
Author

AfromD commented Jan 8, 2018

You have to specify the Udn for the thing configuration. Is there a way to reference it in a rule? I didn't find that anywhere. If it is as easy as SonosSchlafzimmer.udn, I didn't see anyone using that thus far.
I am still learning how the objects and structures in OH all work together, so might well be I am just unaware of things.

@lolodomo
Copy link
Contributor

lolodomo commented Jan 8, 2018

The UDN is already set as thing setting and thing property, that will be strange to add a channel for that.

I will have to check but you can probably use the name you use in the thing UID rather than the UDN in case you have not the default thing UID with UDN.

@AfromD
Copy link
Author

AfromD commented Jan 9, 2018

According to a forum discussion, thing properties are not available to rules. In that case, it would be no harm to expose a property that is needed for commands in an item I think.

@maggu2810
Copy link
Contributor

maggu2810 commented Jan 9, 2018

In that case we should think about whether properties could be made readable by rules instead of adding channels only because we want to access that information in rules.
Similar to: #1654, #3001

@AfromD
Copy link
Author

AfromD commented Jan 9, 2018

Or being creative, adjusting all methods that require the UDN to accept a thing as parameter and then figure out the UDN internally.

@lsiepel
Copy link

lsiepel commented Jan 12, 2018

Adding a method overload would be easier to use over UDN strings from users perspective:
sendCommand(SonosFernseher_Add, SonosBadezimmer)

@cweitkamp
Copy link
Contributor

we should think about whether properties could be made readable by rules

I second that idea. It would be a great advantage if we can access the properties of things in rules.

@kaikreuzer
Copy link
Contributor

I agree with @maggu2810 and @cweitkamp. Adding a channel for the UDN doesn't really make any sense, so I'll close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants