In thing-type.xml
I have defined one thing and one channel. The thing does not have channels in XML because they are known only during runtime. t add them I’m using editThing()
method (in ThingHandler). The problem I have is how to get channel (that is defined in XML) in Java code?
Below I’m attaching code samples:
<thing-type id="supla-io-device">
<supported-bridge-type-refs>
<bridge-type-ref id="suplaCloudBridge"/>
</supported-bridge-type-refs>
<label>Supla Device</label>
<description>
Thing that represents devices added to Supla Cloud. All channels will be discovered after connecting to Supla Cloud.
</description>
<config-description>
<parameter name="supla-cloud-id" type="integer" required="true">
<label>ID</label>
</parameter>
</config-description>
</thing-type>
<channel-type id="switch-channel">
<item-type>Switch</item-type>
<label>ON/OFF switch</label>
<description>Allows you to turn thing ON/OFF</description>
</channel-type>
Java code, BaseThingHandler
class:
@Override
public void initialize() {
ThingBuilder thingBuilder = editThing();
thingBuilder.withChannels( ??? ); // TODO from where I can get Channel?
updateThing(thingBuilder.build());
}