Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[irobot] iRobot cleaning zone support #11413

Closed
wants to merge 15 commits 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 bundles/org.openhab.binding.ahawastecollection/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
<version>1.8.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<feature name="openhab-binding-ahawastecollection" description="aha Waste Collection Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle dependency="true">mvn:org.jsoup/jsoup/1.14.3</bundle>
<bundle dependency="true">mvn:org.jsoup/jsoup/1.8.3</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.ahawastecollection/${project.version}</bundle>
</feature>
</features>
14 changes: 6 additions & 8 deletions bundles/org.openhab.binding.hdpowerview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ However, the configuration parameters are described below:

### Channels for PowerView Hub

Scene, scene group and automation channels will be added dynamically to the binding as they are discovered in the hub.
Each will have an entry in the hub as shown below, whereby different scenes, scene groups and automations
Scene and scene group channels will be added dynamically to the binding as they are discovered in the hub.
Each scene/scene group channel will have an entry in the hub as shown below, whereby different scenes/scene groups
have different `id` values:

| Channel Group | Channel | Item Type | Description |
|---------------|---------|-----------|-------------|
| scenes | id | Switch | Setting this to ON will activate the scene. Scenes are stateless in the PowerView hub; they have no on/off state. Note: include `{autoupdate="false"}` in the item configuration to avoid having to reset it to off after use. |
| sceneGroups | id | Switch | Setting this to ON will activate the scene group. Scene groups are stateless in the PowerView hub; they have no on/off state. Note: include `{autoupdate="false"}` in the item configuration to avoid having to reset it to off after use. |
| automations | id | Switch | Setting this to ON will enable the automation, while OFF will disable it. |
| Channel | Item Type | Description |
|----------|-----------| ------------|
| id | Switch | Turning this to ON will activate the scene/scene group. Scenes/scene groups are stateless in the PowerView hub; they have no on/off state. Note: include `{autoupdate="false"}` in the item configuration to avoid having to reset it to off after use. |

### Channels for PowerView Shade

Expand Down Expand Up @@ -183,7 +181,7 @@ Switch Living_Room_Shade_Battery_Low_Alarm "Living Room Shade Battery Low Alarm
Scene items:

```
Switch Living_Room_Shades_Scene_Heart "Living Room Shades Scene Heart" <blinds> (g_Shades_Scene_Trigger) {channel="hdpowerview:hub:g24:scenes#22663", autoupdate="false"}
Switch Living_Room_Shades_Scene_Heart "Living Room Shades Scene Heart" <blinds> (g_Shades_Scene_Trigger) {channel="hdpowerview:hub:g24:22663", autoupdate="false"}
```

### `demo.sitemap` File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @author Andy Lintner - Initial contribution
* @author Andrew Fiddian-Green - Added support for secondary rail positions
* @author Jacob Laursen - Add support for scene groups and automations
* @author Jacob Laursen - Add support for scene groups
*/
@NonNullByDefault
public class HDPowerViewBindingConstants {
Expand All @@ -46,13 +46,8 @@ public class HDPowerViewBindingConstants {
public static final String CHANNEL_SHADE_BATTERY_VOLTAGE = "batteryVoltage";
public static final String CHANNEL_SHADE_SIGNAL_STRENGTH = "signalStrength";

public static final String CHANNEL_GROUP_SCENES = "scenes";
public static final String CHANNEL_GROUP_SCENE_GROUPS = "sceneGroups";
public static final String CHANNEL_GROUP_AUTOMATIONS = "automations";

public static final String CHANNELTYPE_SCENE_ACTIVATE = "scene-activate";
public static final String CHANNELTYPE_SCENE_GROUP_ACTIVATE = "scene-group-activate";
public static final String CHANNELTYPE_AUTOMATION_ENABLED = "automation-enabled";

public static final List<String> NETBIOS_NAMES = Arrays.asList("PDBU-Hub3.0", "PowerView-Hub");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*/
package org.openhab.binding.hdpowerview.internal;

import java.util.Locale;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.i18n.LocaleProvider;
Expand Down Expand Up @@ -46,8 +44,4 @@ public String getText(String key, @Nullable Object... arguments) {
}
return key;
}

public Locale getLocale() {
return localeProvider.getLocale();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,20 @@
import org.openhab.binding.hdpowerview.internal.api.requests.ShadeStop;
import org.openhab.binding.hdpowerview.internal.api.responses.SceneCollections;
import org.openhab.binding.hdpowerview.internal.api.responses.Scenes;
import org.openhab.binding.hdpowerview.internal.api.responses.ScheduledEvents;
import org.openhab.binding.hdpowerview.internal.api.responses.Shade;
import org.openhab.binding.hdpowerview.internal.api.responses.Shades;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;

/**
* JAX-RS targets for communicating with an HD PowerView hub
*
* @author Andy Lintner - Initial contribution
* @author Andrew Fiddian-Green - Added support for secondary rail positions
* @author Jacob Laursen - Add support for scene groups and automations
* @author Jacob Laursen - Add support for scene groups
*/
@NonNullByDefault
public class HDPowerViewWebTargets {
Expand All @@ -68,7 +65,6 @@ public class HDPowerViewWebTargets {
private final String scenes;
private final String sceneCollectionActivate;
private final String sceneCollections;
private final String scheduledEvents;

private final Gson gson = new Gson();
private final HttpClient httpClient;
Expand Down Expand Up @@ -111,7 +107,6 @@ public HDPowerViewWebTargets(HttpClient httpClient, String ipAddress) {
scenes = base + "scenes/";
sceneCollectionActivate = base + "sceneCollections";
sceneCollections = base + "sceneCollections/";
scheduledEvents = base + "scheduledevents";
this.httpClient = httpClient;
}

Expand Down Expand Up @@ -194,41 +189,6 @@ public void activateSceneCollection(int sceneCollectionId) throws HubProcessingE
Query.of("sceneCollectionId", Integer.toString(sceneCollectionId)), null);
}

/**
* Fetches a JSON package that describes all scheduled events in the hub, and wraps it in
* a ScheduledEvents class instance
*
* @return ScheduledEvents class instance
* @throws JsonParseException if there is a JSON parsing error
* @throws HubProcessingException if there is any processing error
* @throws HubMaintenanceException if the hub is down for maintenance
*/
public @Nullable ScheduledEvents getScheduledEvents()
throws JsonParseException, HubProcessingException, HubMaintenanceException {
String json = invoke(HttpMethod.GET, scheduledEvents, null, null);
return gson.fromJson(json, ScheduledEvents.class);
}

/**
* Enables or disables a scheduled event in the hub.
*
* @param scheduledEventId id of the scheduled event to be enabled or disabled
* @param enable true to enable scheduled event, false to disable
* @throws JsonParseException if there is a JSON parsing error
* @throws JsonSyntaxException if there is a JSON syntax error
* @throws HubProcessingException if there is any processing error
* @throws HubMaintenanceException if the hub is down for maintenance
*/
public void enableScheduledEvent(int scheduledEventId, boolean enable)
throws JsonParseException, HubProcessingException, HubMaintenanceException {
String uri = scheduledEvents + "/" + scheduledEventId;
String json = invoke(HttpMethod.GET, uri, null, null);
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
JsonObject scheduledEventObject = jsonObject.get("scheduledEvent").getAsJsonObject();
scheduledEventObject.addProperty("enabled", enable);
invoke(HttpMethod.PUT, uri, null, jsonObject.toString());
}

/**
* Invoke a call on the hub server to retrieve information or send a command
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.eclipse.jdt.annotation.Nullable;

/**
* State of all Scene Collections in an HD PowerView hub
* State of all Scenes in an HD PowerView hub
*
* @author Jacob Laursen - Initial contribution
*/
Expand All @@ -38,45 +38,13 @@ public class SceneCollections {
*/
@SuppressWarnings("null")
@NonNullByDefault
public static class SceneCollection implements Comparable<SceneCollection> {
public static class SceneCollection {
public int id;
public @Nullable String name;
public int order;
public int colorId;
public int iconId;

@Override
public boolean equals(@Nullable Object o) {
if (o == this) {
return true;
}
if (!(o instanceof SceneCollection)) {
return false;
}
SceneCollection other = (SceneCollection) o;

return this.id == other.id && this.name.equals(other.name) && this.order == other.order
&& this.colorId == other.colorId && this.iconId == other.iconId;
}

@Override
public final int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + id;
result = prime * result + (name == null ? 0 : name.hashCode());
result = prime * result + order;
result = prime * result + colorId;
result = prime * result + iconId;

return result;
}

@Override
public int compareTo(SceneCollection other) {
return Integer.compare(order, other.order);
}

public String getName() {
return new String(Base64.getDecoder().decode(name), StandardCharsets.UTF_8);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,14 @@ public class Scenes {
*/
@SuppressWarnings("null")
@NonNullByDefault
public static class Scene implements Comparable<Scene> {
public static class Scene {
public int id;
public @Nullable String name;
public int roomId;
public int order;
public int colorId;
public int iconId;

@Override
public boolean equals(@Nullable Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Scene)) {
return false;
}
Scene other = (Scene) o;

return this.id == other.id && this.name.equals(other.name) && this.roomId == other.roomId
&& this.order == other.order && this.colorId == other.colorId && this.iconId == other.iconId;
}

@Override
public final int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + id;
result = prime * result + (name == null ? 0 : name.hashCode());
result = prime * result + roomId;
result = prime * result + order;
result = prime * result + colorId;
result = prime * result + iconId;

return result;
}

@Override
public int compareTo(Scene other) {
return Integer.compare(order, other.order);
}

public String getName() {
return new String(Base64.getDecoder().decode(name), StandardCharsets.UTF_8);
}
Expand Down
Loading