Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse SmartHome » channel: change state pattern dynamically
channel: change state pattern dynamically [message #1733762] Tue, 31 May 2016 13:51 Go to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 103
Registered: August 2014
Senior Member

I have a device that reports energy and power consumption.
The consumer is wired to the device, so the device itself does not know the characteristics of the energy and power consumption.

The reporting of the device itself can be configured.
The unit the value (always integer) is reported (e.g. energy: Ws, Wh, kWh) and some other stuff.

I would like to use thing or channel configuration to leave it to the user to configure the measurement reporting.
Depend on the selection I want to change the state pattern of the channel:

  • %d Ws
  • %d Wh
  • %d kWh


The pattern is stored in the channel-type and not in the channel, so I assume it is not possible ATM.

Is there any way to handle this use case?

The last resort is to use a String item-type for the channel and build the "<value> <unit>" pattern in the code, but I don't like that.
Re: channel: change state pattern dynamically [message #1763837 is a reply to message #1733762] Sun, 21 May 2017 20:40 Go to previous message
Peter Kreutzer is currently offline Peter KreutzerFriend
Messages: 3
Registered: May 2017
Junior Member
hi ,

i do have a similar problem.
I am currently writing a binding for openhab for a meter device.
As the meter device send it measurement data as OBIS i get the unit of the values from the meter.

When initializing the thing a build the channels according the initial received values.

How can i problematically change the pattern of the state.
I have tried with below code but the pattern is not showing in paperUI.

       
ChannelTypeUID channelTypeUID = new ChannelTypeUID(BINDING_ID, CHANNEL_NUMBER);
Map<String, String> properties = new HashMap<String, String>();

properties.put("obis", obis);
properties.put("category", "Energy");
 
Configuration configuration = new Configuration();
configuration.put("state.pattern", "%d " + obisUnit);
       
Channel channel = ChannelBuilder.create(new ChannelUID(channelUID), itemType).withLabel(obis)
                .withDescription("OBIS data value").withProperties(properties).withConfiguration(configuration)
                .withType(channelTypeUID).build();


thanks
Peter
Previous Topic:Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
Next Topic:Thing configuration does not show boolean thing parameter in paperUI
Goto Forum:
  


Current Time: Thu Nov 15 05:03:11 GMT 2018

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

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

Back to the top