[harmonyhub] Updates harmony library, uses strings for ids (#16646)

See #6732

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Dan Cunningham 2024-04-12 13:35:12 -06:00 committed by Ciprian Pascu
parent 3eec2ac20b
commit 95f709e625
2 changed files with 13 additions and 20 deletions

View File

@ -22,7 +22,7 @@
<dependency>
<groupId>com.github.digitaldan</groupId>
<artifactId>harmony-client</artifactId>
<version>1.1.6</version>
<version>1.1.7</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -32,7 +32,6 @@ import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.harmonyhub.internal.HarmonyHubDynamicTypeProvider;
import org.openhab.binding.harmonyhub.internal.config.HarmonyHubConfig;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.NextPreviousType;
import org.openhab.core.library.types.PlayPauseType;
import org.openhab.core.library.types.RewindFastforwardType;
@ -126,26 +125,20 @@ public class HarmonyHubHandler extends BaseBridgeHandler implements HarmonyClien
switch (channel.getUID().getId()) {
case CHANNEL_CURRENT_ACTIVITY:
if (command instanceof DecimalType decimalCommand) {
try {
try {
client.startActivity(decimalCommand.intValue());
} catch (Exception e) {
logger.warn("Could not start activity", e);
}
} else {
try {
try {
int actId = Integer.parseInt(command.toString());
client.startActivity(actId);
} catch (NumberFormatException ignored) {
client.startActivityByName(command.toString());
}
} catch (IllegalArgumentException e) {
logger.warn("Activity '{}' is not known by the hub, ignoring it.", command);
} catch (Exception e) {
logger.warn("Could not start activity", e);
// try starting by ID
client.startActivity(command.toString());
} catch (IllegalArgumentException ignored) {
// if that fails, try starting by name
client.startActivityByName(command.toString());
}
} catch (IllegalArgumentException e) {
logger.warn("Activity '{}' is not known by the hub, ignoring it.", command);
} catch (Exception e) {
logger.warn("Could not start activity", e);
}
break;
case CHANNEL_BUTTON_PRESS:
client.pressButtonCurrentActivity(command.toString());
@ -358,7 +351,7 @@ public class HarmonyHubHandler extends BaseBridgeHandler implements HarmonyClien
// trigger of power-off activity (with ID=-1)
getConfigFuture().thenAccept(config -> {
if (config != null) {
Activity powerOff = config.getActivityById(-1);
Activity powerOff = config.getActivityById("-1");
if (powerOff != null) {
triggerChannel(CHANNEL_ACTIVITY_STARTING_TRIGGER, getEventName(powerOff));
}