change states of a channel [message #1778076] |
Sat, 09 December 2017 08:53 |
Nils Billing Messages: 13 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:
when I click on it:
I don't understand it! Can anyone explain to me what I'm doing wrong?
-
Attachment: paperui1.jpg
(Size: 3.89KB, Downloaded 531 times) -
Attachment: paperui2.jpg
(Size: 4.48KB, Downloaded 529 times)
[Updated on: Sat, 09 December 2017 08:54] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04566 seconds