Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[harmonyhub] Fixes #2497 #2634

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/binding/org.openhab.binding.harmonyhub/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ <h3>Third Party Content</h3>
https://www.eclipse.org/legal/epl-v10.html
</pre></p>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.concurrent.TimeUnit;

import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService;
import org.eclipse.smarthome.config.discovery.DiscoveryResult;
import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.ThingUID;
Expand Down Expand Up @@ -286,9 +285,7 @@ private void hubDiscovered(String host, String id, String friendlyName) {

ThingUID uid = new ThingUID(HarmonyHubBindingConstants.HARMONY_HUB_THING_TYPE,
id.replaceAll("[^A-Za-z0-9\\-_]", ""));
thingDiscovered(DiscoveryResultBuilder.create(uid)
.withProperties(properties)
.withLabel("HarmonyHub " + friendlyName)
.build());
thingDiscovered(DiscoveryResultBuilder.create(uid).withProperties(properties)
.withLabel("HarmonyHub " + friendlyName).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class HarmonyHubHandler extends BaseBridgeHandler implements HarmonyHubLi

private int heartBeatInterval;

private Activity currentActivity;

public HarmonyHubHandler(Bridge bridge, HarmonyHubHandlerFactory factory) {
super(bridge);
this.factory = factory;
Expand All @@ -103,10 +105,15 @@ public void handleCommand(ChannelUID channelUID, Command command) {
} else if (command instanceof StringType) {
try {
try {
int actId = Integer.parseInt(command.toString());
client.startActivity(actId);
Integer actId = Integer.parseInt(command.toString());
if (currentActivity == null || !actId.equals(currentActivity.getId())) {
client.startActivity(actId);
}
} catch (NumberFormatException ignored) {
client.startActivityByName(command.toString());
String activity = command.toString();
if (currentActivity == null || !activity.equals(currentActivity.getLabel())) {
client.startActivityByName(activity);
}
}
} catch (Exception e) {
logger.error("Could not start activity", e);
Expand Down Expand Up @@ -258,6 +265,7 @@ private void cancelRetry() {

private void updateState(Activity activity) {
logger.debug("Updating current activity to {}", activity.getLabel());
currentActivity = activity;
updateState(new ChannelUID(getThing().getUID(), HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY),
new StringType(activity.getLabel()));
}
Expand Down