Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse SmartHome » Change Channel pattern based on its configuration
Change Channel pattern based on its configuration [message #1772482] Mon, 11 September 2017 10:07 Go to next message
Marco Ho is currently offline Marco HoFriend
Messages: 3
Registered: June 2016
Junior Member
Hello,

I'm currently developing a binding and have an issue with the following usecase.

I have a channel with a Number item which holds information of a sensor.
The binding does not know what type of unit the measured value has. It could be °Celsius, °Fahrenheit or something else entirely.

I've added a config parameter to the channel so that the user can select the correct unit for this sensor.

Channels have a pattern attribute in their StateDescription, which can be set to patterns like "%.1f °C". This works fine when defined in the XML describing the channel.

How do i update that pattern when the user changes the channels configuration?

Where would i react to a channel configuration update to apply these changes?

The ChannelBuilder does not seem to provide a way to change this. It looks like defining a different ChannelType for each different unit is the only way.
I guess I would need to have the ChannelBuilder change the ChannelTypeUID when the user updates the channels configuration. That might create a lot of unnecessary redundancy in ChannelTypes and config descriptions.
Re: Change Channel pattern based on its configuration [message #1772488 is a reply to message #1772482] Mon, 11 September 2017 12:38 Go to previous messageGo to next message
Henning Treu is currently offline Henning TreuFriend
Messages: 42
Registered: April 2017
Member
Hi,

you have three different options here:

  1. omit the unit in the channels state description entirely. The user has to provide item state descriptions in the items file or sitemap with the proper unit. This is how the WeatherUnderground binding does it right now.
  2. implement your own StateDescriptionProvider and resolve the Channel for the given item name. Then return a state Description matching the unit the user chose on the channel. This works in combination with 1) resulting in PaperUI not showing a unit but other UIs showing the unit the user configured.
  3. Preferred: Wait until https://github.com/eclipse/smarthome/pull/1857 is done and directly implement support for the frameworks QuantityType. This way your binding can update the channel with any unit and the framework will convert it to the local default or the specific unit the user configured on the item or in the sitemap.


I would strongly suggest to wait for option 3 as it is in development right now and will be really nice to solve your problem. The WeatherUnderground binding gets updated to with the mentioned PR so you can already have a look on how this is done.

Cheers,
Henning

[Updated on: Mon, 11 September 2017 12:43]

Report message to a moderator

Re: Change Channel pattern based on its configuration [message #1772489 is a reply to message #1772488] Mon, 11 September 2017 12:55 Go to previous message
Marco Ho is currently offline Marco HoFriend
Messages: 3
Registered: June 2016
Junior Member
Thank you.

I'll go with 1) until 3) is done.
Previous Topic:Need help with understanding Architecture
Next Topic:Sudden Build Problem
Goto Forum:
  


Current Time: Sat Nov 17 18:06:07 GMT 2018

Powered by FUDForum. Page generated in 0.01840 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top