mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[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:
parent
3eec2ac20b
commit
95f709e625
@ -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>
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user