Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse SmartHome » change states of a channel
change states of a channel [message #1778076] Sat, 09 December 2017 08:53 Go to next message
Nils Billing is currently offline Nils BillingFriend
Messages: 8
Registered: September 2017
Junior Member
hi,

I want to change state values of a channels (e.g. like in YamahaZoneThingHandler.java from yamahareceiver binding).

That's my channel and channel-type:
...
<channel id="movepreset" typeId="movepreset-channel" />
...
<channel-type id="movepreset-channel">
   <item-type>String</item-type>
      <label>Move to preset</label>
      <description>Moving to preset</description>
      <state pattern="%s">
         <options>
		<option value="HOME">home</option>
	</options>
     </state>
</channel-type>
....


That's my code to cahnge the states:
    protected void thingStructureChanged() {

        final ChannelTypeUID channelTypePresetUID = new ChannelTypeUID(
                MyBindingConstants.BINDING_ID, "movepreset-channel");
        
        ChannelType templateType = TypeResolver.resolve(channelTypePresetUID);

        List<StateOption> options = new ArrayList<>();
        options.add(new StateOption("TEST1", "Test 1"));
        options.add(new StateOption("TEST2", "Test 2"));

        StateDescription state = new StateDescription(null, null, null, "%s", false, options);

        ChannelUID movepresetChannelUID = new ChannelUID(thing.getUID(), "movepreset");
        
        ChannelTypeUID channelTypeUID = new ChannelTypeUID(movepresetChannelUID.getAsString());
        ChannelType channelType = new ChannelType(channelTypeUID, false, "String", templateType.getKind(),
                templateType.getLabel(), templateType.getDescription(), templateType.getCategory(),
                templateType.getTags(), state, templateType.getEvent(), templateType.getConfigDescriptionURI());
        
        Channel channel = ChannelBuilder.create(movepresetChannelUID, "String").withType(channelTypeUID).build();
        
        // Remove the old channel and add the new channel            
        updateThing(editThing().withoutChannel(movepresetChannelUID).withChannel(channel).build());
    }


The original channel seems to be removed and a new empty channel was added.
In PaperUI it looks like that:

index.php/fa/31528/0/

when I click on it:
index.php/fa/31529/0/

I don't understand it! Can anyone explain to me what I'm doing wrong?




  • Attachment: paperui1.jpg
    (Size: 3.89KB, Downloaded 222 times)
  • Attachment: paperui2.jpg
    (Size: 4.48KB, Downloaded 214 times)

[Updated on: Sat, 09 December 2017 08:54]

Report message to a moderator

Re: change states of a channel [message #1778170 is a reply to message #1778076] Mon, 11 December 2017 13:20 Go to previous messageGo to next message
Nils Billing is currently offline Nils BillingFriend
Messages: 8
Registered: September 2017
Junior Member
is there anything else what I missed with the created channeltype???
 ChannelType channelType = new ChannelType(channelTypeUID, false ...


for testing I add ".withLabel(..." to create call
Channel channel = ChannelBuilder.create(movepresetChannelUID, "String").withType(channelTypeUID)
                .withLabel("Test label").build();


the label is added probaply to the channel:
index.php/fa/31543/0/

I don't get it!
  • Attachment: paperui3.jpg
    (Size: 4.00KB, Downloaded 155 times)
Re: change states of a channel [message #1778328 is a reply to message #1778170] Wed, 13 December 2017 07:53 Go to previous messageGo to next message
Henning Treu is currently offline Henning TreuFriend
Messages: 37
Registered: April 2017
Member
Hi Nils,

instead of adding/removing channel types and channels you should implement your own ConfigDescriptionProvider. With this you can dynamically change the config options provided for a specific channel type.

Hope that helps. Cheers
Henning

Re: change states of a channel [message #1778417 is a reply to message #1778328] Thu, 14 December 2017 06:05 Go to previous messageGo to next message
Nils Billing is currently offline Nils BillingFriend
Messages: 8
Registered: September 2017
Junior Member
Hi Henning,

thank you for your response. I've just seen this the ConfigDescriptionProvider yesterday.
I will give it a try.
Re: change states of a channel [message #1779080 is a reply to message #1778417] Tue, 02 January 2018 09:50 Go to previous message
Nils Billing is currently offline Nils BillingFriend
Messages: 8
Registered: September 2017
Junior Member
hi Henning,
happy new year!
I've tried now but can't get it work. i've implemented an OptinonProvider which imlpements ConfigDescriptionProvider, ConfigOptionProvider (like Chris in his zwave binding). I create the xml configuration for this OptionProvider In OSGI-INF.
When I start openhab the OptionProvider is only called for my bridge properties but not for my thing with the channels.
Have you an idea what I doing wrong?
Previous Topic:Eclipse Kura
Next Topic:ComboBox for selecting a channel value
Goto Forum:
  


Current Time: Fri Jun 22 00:07:25 GMT 2018

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

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

Back to the top