Configure zone on panel even if the channel is not yet linked (#13380)

Signed-off-by: Haavar Valeur <haavar@haavar.com>
This commit is contained in:
Haavar Valeur 2022-09-17 08:02:09 -07:00 committed by GitHub
parent 6805f8461e
commit 7dfb963f92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -328,53 +328,49 @@ public class KonnectedHandler extends BaseThingHandler {
payload.setDiscovery(config.discovery); payload.setDiscovery(config.discovery);
this.getThing().getChannels().forEach(channel -> { this.getThing().getChannels().forEach(channel -> {
// ChannelUID channelId = channel.getUID(); // ChannelUID channelId = channel.getUID();
if (isLinked(channel.getUID())) { // adds channels to list based on last value of Channel ID
// adds linked channels to list based on last value of Channel ID // which is set to a number
// which is set to a number // get the zone number in integer form
// get the zone number in integer form ZoneConfiguration zoneConfig = channel.getConfiguration().as(ZoneConfiguration.class);
ZoneConfiguration zoneConfig = channel.getConfiguration().as(ZoneConfiguration.class); // if the pin is an actuator add to actuator string
// if the pin is an actuator add to actuator string // else add to sensor string
// else add to sensor string // This is determined based off of the accepted item type, contact types are sensors
// This is determined based off of the accepted item type, contact types are sensors // switch types are actuators
// switch types are actuators String channelType = channel.getChannelTypeUID().getAsString();
String channelType = channel.getChannelTypeUID().getAsString(); logger.debug("The channeltypeID is: {}", channelType);
logger.debug("The channeltypeID is: {}", channelType); KonnectedModuleGson module = new KonnectedModuleGson();
KonnectedModuleGson module = new KonnectedModuleGson(); module.setZone(thingID, zoneConfig.zone);
module.setZone(thingID, zoneConfig.zone); if (channelType.contains(CHANNEL_SWITCH)) {
if (channelType.contains(CHANNEL_SWITCH)) { payload.addSensor(module);
payload.addSensor(module); logger.trace("Channel {} will be configured on the konnected alarm panel as a switch", channel);
logger.trace("Channel {} will be configured on the konnected alarm panel as a switch", channel); } else if (channelType.contains(CHANNEL_ACTUATOR)) {
} else if (channelType.contains(CHANNEL_ACTUATOR)) { payload.addActuators(module);
payload.addActuators(module); logger.trace("Channel {} will be configured on the konnected alarm panel as an actuator", channel);
logger.trace("Channel {} will be configured on the konnected alarm panel as an actuator", channel); } else if (channelType.contains(CHANNEL_HUMIDITY)) {
} else if (channelType.contains(CHANNEL_HUMIDITY)) { // the humidity channels do not need to be added because the supported sensor (dht22) is added under
// the humidity channels do not need to be added because the supported sensor (dht22) is added under // the temp sensor
// the temp sensor logger.trace("Channel {} is a humidity channel.", channel);
logger.trace("Channel {} is a humidity channel.", channel); } else if (channelType.contains(CHANNEL_TEMPERATURE)) {
} else if (channelType.contains(CHANNEL_TEMPERATURE)) { logger.trace("Channel {} will be configured on the konnected alarm panel as a temperature sensor",
logger.trace("Channel {} will be configured on the konnected alarm panel as a temperature sensor", channel);
module.setPollInterval(zoneConfig.pollInterval);
logger.trace("The Temperature Sensor Type is: {} ", zoneConfig.dht22);
if (zoneConfig.dht22) {
// add it as a dht22 module
payload.addDht22(module);
logger.trace(
"Channel {} will be configured on the konnected alarm panel as a DHT22 temperature sensor",
channel); channel);
module.setPollInterval(zoneConfig.pollInterval);
logger.trace("The Temperature Sensor Type is: {} ", zoneConfig.dht22);
if (zoneConfig.dht22) {
// add it as a dht22 module
payload.addDht22(module);
logger.trace(
"Channel {} will be configured on the konnected alarm panel as a DHT22 temperature sensor",
channel);
} else {
// add to payload as a DS18B20 module if the parameter is false
payload.addDs18b20(module);
logger.trace(
"Channel {} will be configured on the konnected alarm panel as a DS18B20 temperature sensor",
channel);
}
} else { } else {
logger.debug("Channel {} is of type {} which is not supported by the konnected binding", channel, // add to payload as a DS18B20 module if the parameter is false
channelType); payload.addDs18b20(module);
logger.trace(
"Channel {} will be configured on the konnected alarm panel as a DS18B20 temperature sensor",
channel);
} }
} else { } else {
logger.debug("The Channel {} is not linked to an item", channel.getUID()); logger.debug("Channel {} is of type {} which is not supported by the konnected binding", channel,
channelType);
} }
}); });
// Create Json to Send to Konnected Module // Create Json to Send to Konnected Module