Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Dynamic Channel Groups
Dynamic Channel Groups [message #1718668] Tue, 29 December 2015 01:20 Go to next message
Dan Cunningham is currently offline Dan CunninghamFriend
Messages: 44
Registered: March 2014
Member
Hello All,
I'm having trouble creating channel groups dynamically. My binding consists of a bridge with 1 or more device things with 1 or more channels. The device thing and channels are created dynamically.

My Device Type and Channel type look like so:
    <thing-type id="device">
        <supported-bridge-type-refs>
            <bridge-type-ref id="harmonyHub" />
        </supported-bridge-type-refs>
        <label>Harmony Device</label>
        <description>Logitech Harmony Hub Device</description>
        <properties>
            <property name="name"></property>
        </properties>
        <config-description>
            <parameter name="id" type="integer" required="true">
                <label>id</label>
                <description>Numeric ID of the Harmony Device</description>
            </parameter>
        </config-description>
    </thing-type>

     <channel-type id="sendButtonPress">
        <item-type>Switch</item-type>
        <label>Button Press</label>
        <description>Sends a button press to the device</description>
        <config-description>
            <parameter name="buttonName" type="text"></parameter>
        </config-description>
    </channel-type>


You will notice that the device does not link to a channel in the XML file, this is because a device can have 1 or more (usually a lot more) "sendButtonPress" channels. This is working fine with the following code as well as registering a ChannelTypeProvider:

                    ThingBuilder thingBuilder = editThing();
                    .......
                    Map<String, String> channelProperties = new HashMap<String, String>();
                    channelProperties.put("buttonName", function.getName());

                    ChannelTypeUID channelTypeUID = new ChannelTypeUID(HarmonyHubBindingConstants.BINDING_ID,
                            HarmonyHubBindingConstants.CHANNEL_SEND_BUTTON_PRESS);

                    Channel channel = ChannelBuilder
                            .create(new ChannelUID(getThing().getUID(), function.getName()), "String")
                            .withType(channelTypeUID).withProperties(channelProperties).build();
                    
                     thingBuilder.withChannel(channel);


The Logitech Harmony hub groups these button presses into "control groups" which seem to map nicely to channel groups. The name and number of these groups is not known until I query the device. So I would like to now create channel groups dynamically and link those to a device. Unfortunately I don't think I fully understand the relationship between ChannelGroupTypes Channels and ChannelDefinitions . I have been playing around with the following code :
                 ArrayList<ChannelDefinition> channelDefinitions = new ArrayList<ChannelDefinition>();
                .....
                ChannelDefinition cd = new ChannelDefinition(channel.getUID().getId(), channelTypeUID);
                channelDefinitions.add(cd);
                .......
                ChannelGroupTypeUID groupTypeUID = new ChannelGroupTypeUID(HarmonyHubBindingConstants.BINDING_ID,
                        controlGroup.getName());

                ChannelGroupType groupType = new ChannelGroupType(groupTypeUID, false, controlGroup.getName(),
                        controlGroup.getName() + " Channel Group", channelDefinitions);



I'm using the ChannelTypeProvider to return the newly created ChannelGroupType, but this never seems to be called (unlike my dynamic channels which are working) I'm guessing I'm missing something with the relationship between a ChannelDefinition and the Channel I create dynamically. I also don't understand how a ChannelGroup is tied to a Thing and then how channels are tied to a ChannelGroup. This is clear in the XML, but not in code.

Thanks!
Re: Dynamic Channel Groups [message #1718731 is a reply to message #1718668] Tue, 29 December 2015 14:53 Go to previous message
Dan Cunningham is currently offline Dan CunninghamFriend
Messages: 44
Registered: March 2014
Member
while I'm still curious about how to link channel groups in code, I decided against using channels groups. Once I started going down that road I found the groups that the Logitech API used were too cryptic and not at all useful enough to warrant the added complication to the end user. Additionally I might go from having many (dozens) channels per device that send one button press each to having a single button press channel with the option list dynamically generated. My goal is to have the binding usefull without any user configuration.
Previous Topic:Couldn't access runtime webpage
Next Topic:CalDAV ESH(or OH2) binding
Goto Forum:
  


Current Time: Wed Apr 24 19:50:43 GMT 2024

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

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

Back to the top