Skip to content

Commit

Permalink
fix for openhab#16724 Addon channels not discovered when in cover mod…
Browse files Browse the repository at this point in the history
…e with

Shelly Plus 2PM

Signed-off-by: Markus Michels <markus7017@gmail.com>
  • Loading branch information
markus7017 committed May 11, 2024
1 parent 568630e commit 625088b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ protected boolean initializeThingConfig() {
String saddr = addr.getHostAddress();
if (!ip.equals(saddr)) {
logger.debug("{}: hostname {} resolved to IP address {}", thingName, config.deviceIp, saddr);
config.deviceIp = saddr + (port.isEmpty() ? ip : ip + ":" + port);
config.deviceIp = saddr + (port.isEmpty() ? "" : ":" + port);
}
} catch (UnknownHostException e) {
logger.debug("{}: Unable to resolve hostname {}", thingName, config.deviceIp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ public static Map<String, Channel> createRelayChannels(final Thing thing, final
addChannel(thing, add, rs.autoOff != null, group, CHANNEL_TIMER_AUTOOFF);
}

addAddonChannels(thing, profile, idx, add);

return add;
}

private static void addAddonChannels(final Thing thing, final ShellyDeviceProfile profile, int idx,
Map<String, Channel> add) {
// Shelly 1/1PM and Plus 1/1PM Addon
boolean addon = profile.settings.extSwitch != null && profile.settings.extSwitch.input0 != null
&& idx == getInteger(profile.settings.extSwitch.input0.relayNum);
Expand All @@ -385,11 +392,10 @@ public static Map<String, Channel> createRelayChannels(final Thing thing, final
}
addChannel(thing, add, profile.status.extHumidity != null && profile.status.extHumidity.sensor1 != null,
CHGR_SENSOR, CHANNEL_ESENSOR_HUMIDITY);

addChannel(thing, add, profile.status.extVoltage != null, CHGR_SENSOR, CHANNEL_ESENSOR_VOLTAGE);
addChannel(thing, add, profile.status.extDigitalInput != null, CHGR_SENSOR, CHANNEL_ESENSOR_DIGITALINPUT);
addChannel(thing, add, profile.status.extAnalogInput != null, CHGR_SENSOR, CHANNEL_ESENSOR_ANALOGINPUT);

return add;
}

public static Map<String, Channel> createDimmerChannels(final Thing thing, final ShellyDeviceProfile profile,
Expand Down Expand Up @@ -458,7 +464,8 @@ public static Map<String, Channel> createInputChannels(final Thing thing, final
return add;
}

public static Map<String, Channel> createRollerChannels(Thing thing, final ShellyRollerStatus roller) {
public static Map<String, Channel> createRollerChannels(final Thing thing, final ShellyDeviceProfile profile,
final ShellyRollerStatus roller) {
Map<String, Channel> add = new LinkedHashMap<>();
addChannel(thing, add, true, CHGR_ROLLER, CHANNEL_ROL_CONTROL_CONTROL);
addChannel(thing, add, true, CHGR_ROLLER, CHANNEL_ROL_CONTROL_STATE);
Expand All @@ -474,6 +481,9 @@ public static Map<String, Channel> createRollerChannels(Thing thing, final Shell
addChannel(thing, add, roller.currentPos != null, CHGR_ROLLER, CHANNEL_ROL_CONTROL_FAV);
}
}

addAddonChannels(thing, profile, 0, add);

return add;
}

Expand Down

0 comments on commit 625088b

Please sign in to comment.