Skip to content

Commit

Permalink
[plugwiseha] Add and enhance channels (openhab#12349)
Browse files Browse the repository at this point in the history
* Add two-channels, fix scene and docs

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
  • Loading branch information
lsiepel authored and nemerdaud committed Jun 29, 2022
1 parent 33c6dff commit 9d6d4ec
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 58 deletions.
24 changes: 14 additions & 10 deletions bundles/org.openhab.binding.plugwiseha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The 'Adam' (from hereon called the gateway) needs to be accessible from the open
| - | A Plugwise heating zone configured with at least 1 of the devices below | zone |
| [Adam](https://www.plugwise.com/en_US/products/adam-ha) | The Plugwise Home Automation Bridge is needed to connect to the Adam boiler gateway | gateway |
| [Tom](https://www.plugwise.com/en_US/products/tom) | A Plugwise Home Automation radiator valve | appliance_valve |
| [Floor](https://www.plugwise.com/en_US/products/floor) | A Plugwise Home Automation radiator valve specifically used for floor heating | appliance_valve |
| [Floor](https://www.plugwise.com/en_US/products/floor) | A Plugwise Home Automation radiator valve specifically used for floor heating | appliance_valve |
| [Circle](https://www.plugwise.com/en_US/products/circle) | A power outlet plug that provides energy measurement and switching control of appliances (e.g. floor heating pump) | appliance_pump |
| [Lisa](https://www.plugwise.com/en_US/products/lisa) | A room thermostat (also supports the 'Anna' room thermostat) | appliance_thermostat |
| [Boiler] | A central boiler used for heating and/or domestic hot water | appliance_boiler |
Expand All @@ -39,7 +39,7 @@ You must define a Plugwise Home Automation gateway (Bridge) before defining zone
#### Plugwise Home Automation gateway (Bridge):

| Parameter | Description | Config | Default |
| --------- | ----------------------------------------------------------------------- | -------- | ------- |
|-----------|-------------------------------------------------------------------------|----------|---------|
| host | The IP address or hostname of the Adam HA gateway | Required | 'adam' |
| username | The username for the Adam HA gateway | Optional | 'smile' |
| smileID | The 8 letter code on the sticker on the back of the Adam boiler gateway | Required | - |
Expand All @@ -54,14 +54,14 @@ You must define a Plugwise Home Automation gateway (Bridge) before defining zone
#### Plugwise Home Automation appliance (`appliance_valve`):

| Parameter | Description | Config | Default |
| -------------------- | ------------------------------------------------------------------------------------------------------------------ | -------- | ------- |
|----------------------|--------------------------------------------------------------------------------------------------------------------|----------|---------|
| id | The unique ID of the radiator valve appliance | Required | - |
| lowBatteryPercentage | Battery charge remaining at which to trigger battery low warning. (*Only applicable for battery operated devices*) | Optional | 15 |

#### Plugwise Home Automation appliance (`appliance_thermostat`):

| Parameter | Description | Config | Default |
| -------------------- | ------------------------------------------------------------------------------------------------------------------ | -------- | ------- |
|----------------------|--------------------------------------------------------------------------------------------------------------------|----------|---------|
| id | The unique ID of the room thermostat appliance | Required | - |
| lowBatteryPercentage | Battery charge remaining at which to trigger battery low warning. (*Only applicable for battery operated devices*) | Optional | 15 |

Expand All @@ -75,7 +75,7 @@ You must define a Plugwise Home Automation gateway (Bridge) before defining zone
#### Plugwise Home Automation boiler (`appliance_boiler`):

| Parameter | Description | Config | Default |
| --------- | --------------------------- | -------- | ------- |
|-----------|-----------------------------|----------|---------|
| id | The unique ID of the boiler | Required | - |

## Channels
Expand All @@ -92,9 +92,11 @@ You must define a Plugwise Home Automation gateway (Bridge) before defining zone
| chState | Switch | Yes | The current central heating state of the boiler |
| dhwState | Switch | Yes | The current domestic hot water state of the boiler |
| waterPressure | Number:Pressure | Yes | The current water pressure of the boiler |
| presetScene | String | Yes | The current active scene for the zone |
| presetScene | String | No | The current active scene for the zone |
| regulationControl | String | No | Toggle current regulation control (Active, Passive, Off) for the zone |
| coolingAllowed | Switch | No | Toggle the cooling allowed of a zone ON/OFF |
| valvePosition | Number | Yes | The current position of the valve |
| preHeat | Switch | Yes | Toggle the pre heating of a zone ON/OFF |
| preHeat | Switch | No | Toggle the pre heating of a zone ON/OFF |
| coolingState | Switch | Yes | The current cooling state of the boiler |
| intendedBoilerTemp | Number:Temperature | Yes | The intended boiler temperature |
| flameState | Switch | Yes | The flame state of the boiler |
Expand All @@ -107,8 +109,6 @@ You must define a Plugwise Home Automation gateway (Bridge) before defining zone
| dhwSetpoint | Number:Temperature | Yes | The domestic hot water setpoint |
| maxBoilerTemperature | Number:Temperature | Yes | The maximum temperature of the boiler |
| dhwComfortMode | Switch | Yes | The domestic hot water confortmode |
|


## Full Example

Expand All @@ -131,8 +131,10 @@ Replace `$device_id` accordingly.
```
Number:Temperature living_room_zone_temperature "Zone temperature" {channel="plugwiseha:zone:home:living_room_zone:temperature"}
Number:Temperature living_room_zone_temperature_setpoint "Zone temperature setpoint" {channel="plugwiseha:zone:home:living_room_zone:setpointTemperature"}
Number:Temperature living_room_zone_preset_scene "Zone preset scene" {channel="plugwiseha:zone:home:living_room_zone:presetScene"}
String living_room_zone_preset_scene "Zone preset scene" {channel="plugwiseha:zone:home:living_room_zone:presetScene"}
Switch living_room_zone_preheat "Zone preheat enabled" {channel="plugwiseha:zone:home:living_room_zone:preHeat"}
String living_room_zone_cooling "Zone cooling enabled" {channel="plugwiseha:zone:home:living_room_zone:coolingAllowed"}
String living_room_zone_regulation_control "Zone regulation control" {channel="plugwiseha:zone:home:living_room_zone:regulationControl"}
Number:Temperature living_room_radiator_temperature "Radiator valve temperature" {channel="plugwiseha:appliance_valve:home:living_room_radiator:temperature"}
Number:Temperature living_room_radiator_temperature_setpoint "Radiator valve temperature setpoint" {channel="plugwiseha:appliance_valve:home:living_room_radiator:setpointTemperature"}
Expand Down Expand Up @@ -181,6 +183,8 @@ sitemap plugwiseha label="PlugwiseHA Binding"
Setpoint item=living_room_zone_temperature_setpoint label="Living room [%.1f °C]" minValue=5.0 maxValue=25 step=0.5
Text item=living_room_zone_presetScene
Switch item=living_room_zone_preheat
Text item=living_room_zone_regulation_control
Switch item=living_room_zone_cooling
Text item=living_room_radiator_temperature
Setpoint item=living_room_radiator_temperature_setpoint label="Living room [%.1f °C]" minValue=5.0 maxValue=25 step=0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ public class PlugwiseHABindingConstants {
public static final String LOCATION_PROPERTY_FUNCTIONALITIES = "functionalities";

// List of all Channel IDs
public static final String ZONE_COOLING_CHANNEL = "coolingAllowed";
public static final String ZONE_SETPOINT_CHANNEL = "setpointTemperature";
public static final String ZONE_TEMPERATURE_CHANNEL = "temperature";
public static final String ZONE_PRESETSCENE_CHANNEL = "presetScene";
public static final String ZONE_PREHEAT_CHANNEL = "preHeat";
public static final String ZONE_REGULATION_CHANNEL = "regulationControl";

public static final String APPLIANCE_SETPOINT_CHANNEL = "setpointTemperature";
public static final String APPLIANCE_TEMPERATURE_CHANNEL = "temperature";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,76 +322,80 @@ public void setOffsetTemperature(Appliance appliance, Double temperature) throws
}
}

public void switchRelay(Appliance appliance, String state) throws PlugwiseHAException {
List<String> allowStates = Arrays.asList("on", "off");
if (allowStates.contains(state.toLowerCase())) {
if (state.toLowerCase().equals("on")) {
switchRelayOn(appliance);
} else {
switchRelayOff(appliance);
}
}
public void setPreHeating(Location location, Boolean state) throws PlugwiseHAException {
PlugwiseHAControllerRequest<Void> request = newRequest(Void.class);
Optional<ActuatorFunctionality> thermostat = location.getActuatorFunctionalities().getFunctionalityThermostat();

request.setPath("/core/locations");
request.addPathParameter("id", String.format("%s/thermostat", location.getId()));
request.addPathParameter("id", String.format("%s", thermostat.get().getId()));
request.setBodyParameter(new ActuatorFunctionalityThermostat(state, null, null));

executeRequest(request);
}

public void setPreHeating(Location location, Boolean state) throws PlugwiseHAException {
public void setAllowCooling(Location location, Boolean state) throws PlugwiseHAException {
PlugwiseHAControllerRequest<Void> request = newRequest(Void.class);
Optional<ActuatorFunctionality> thermostat = location.getActuatorFunctionalities().getFunctionalityThermostat();

request.setPath("/core/locations");
request.addPathParameter("id", String.format("%s/thermostat", location.getId()));
request.addPathParameter("id", String.format("%s", thermostat.get().getId()));
request.setBodyParameter(new ActuatorFunctionalityThermostat(state));
request.setBodyParameter(new ActuatorFunctionalityThermostat(null, state, null));

executeRequest(request);
}

public void switchRelayOn(Appliance appliance) throws PlugwiseHAException {
public void setRegulationControl(Location location, String state) throws PlugwiseHAException {
List<String> allowStates = Arrays.asList("active", "passive", "off");
if (!allowStates.contains(state.toLowerCase())) {
this.logger.warn("Trying to set the regulation control to an invalid state");
return;
}

PlugwiseHAControllerRequest<Void> request = newRequest(Void.class);
Optional<ActuatorFunctionality> thermostat = location.getActuatorFunctionalities().getFunctionalityThermostat();

request.setPath("/core/appliances");
request.addPathParameter("id", String.format("%s/relay", appliance.getId()));
request.setBodyParameter(new ActuatorFunctionalityRelay("on"));
request.setPath("/core/locations");
request.addPathParameter("id", String.format("%s/thermostat", location.getId()));
request.addPathParameter("id", String.format("%s", thermostat.get().getId()));
request.setBodyParameter(new ActuatorFunctionalityThermostat(null, null, state));

executeRequest(request);
}

public void switchRelayOff(Appliance appliance) throws PlugwiseHAException {
public void setRelay(Appliance appliance, Boolean state) throws PlugwiseHAException {
PlugwiseHAControllerRequest<Void> request = newRequest(Void.class);

request.setPath("/core/appliances");
request.addPathParameter("id", String.format("%s/relay", appliance.getId()));
request.setBodyParameter(new ActuatorFunctionalityRelay("off"));
request.setBodyParameter(new ActuatorFunctionalityRelay(state ? "on" : "off"));

executeRequest(request);
}

public void switchRelayLock(Appliance appliance, String state) throws PlugwiseHAException {
List<String> allowStates = Arrays.asList("on", "off");
if (allowStates.contains(state.toLowerCase())) {
if (state.toLowerCase().equals("on")) {
switchRelayLockOn(appliance);
} else {
switchRelayLockOff(appliance);
}
}
}

public void switchRelayLockOff(Appliance appliance) throws PlugwiseHAException {
public void setRelayLock(Appliance appliance, Boolean state) throws PlugwiseHAException {
PlugwiseHAControllerRequest<Void> request = newRequest(Void.class);

request.setPath("/core/appliances");
request.addPathParameter("id", String.format("%s/relay", appliance.getId()));
request.setBodyParameter(new ActuatorFunctionalityRelay(null, false));
request.setBodyParameter(new ActuatorFunctionalityRelay(null, state));

executeRequest(request);
}

public void switchRelayLockOn(Appliance appliance) throws PlugwiseHAException {
public void setPresetScene(Location location, String state) throws PlugwiseHAException {
List<String> allowStates = Arrays.asList("home", "asleep", "away", "vacation", "no_frost");
if (!allowStates.contains(state.toLowerCase())) {
this.logger.warn("Trying to set the preset scene to an invalid state");
return;
}

PlugwiseHAControllerRequest<Void> request = newRequest(Void.class);

request.setPath("/core/appliances");
request.addPathParameter("id", String.format("%s/relay", appliance.getId()));
request.setBodyParameter(new ActuatorFunctionalityRelay(null, true));
request.setPath("/core/locations");
request.addPathParameter("id", String.format("%s", location.getId()));
request.setBodyParameter(new Location(state));

executeRequest(request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public Optional<Boolean> getRelayLockState() {
.map(Boolean::parseBoolean);
}

public Optional<String> getRegulationControl() {
return this.getFunctionalityThermostat().flatMap(ActuatorFunctionality::getRegulationControl);
}

public Optional<Boolean> getCoolingAllowed() {
return this.getFunctionalityThermostat().flatMap(ActuatorFunctionality::getCoolingAllowed)
.map(Boolean::parseBoolean);
}

public Optional<Boolean> getPreHeatState() {
return this.getFunctionalityThermostat().flatMap(ActuatorFunctionality::getPreHeatState)
.map(Boolean::parseBoolean);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public class ActuatorFunctionality extends PlugwiseBaseModel implements Plugwise
private String resolution;
private String lock;

@XStreamAlias("regulation_control")
private String regulationControl;

@XStreamAlias("cooling_allowed")
private String coolingAllowed;

@XStreamAlias("preheating_allowed")
private String preHeat;

Expand Down Expand Up @@ -75,6 +81,14 @@ public ZonedDateTime getUpdatedDate() {
return updatedDate;
}

public Optional<String> getRegulationControl() {
return Optional.ofNullable(regulationControl);
}

public Optional<String> getCoolingAllowed() {
return Optional.ofNullable(coolingAllowed);
}

public Optional<String> getPreHeatState() {
return Optional.ofNullable(preHeat);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,22 @@ public class ActuatorFunctionalityThermostat extends ActuatorFunctionality {
@XStreamAlias("preheating_allowed")
private Boolean preheatingAllowed;

@SuppressWarnings("unused")
@XStreamAlias("cooling_allowed")
private Boolean coolingAllowed;

@SuppressWarnings("unused")
@XStreamAlias("regulation_control")
private String regulationControl;

public ActuatorFunctionalityThermostat(Double temperature) {
this.setpoint = temperature;
}

public ActuatorFunctionalityThermostat(Boolean preheatingAllowed) {
public ActuatorFunctionalityThermostat(Boolean preheatingAllowed, Boolean coolingAllowed,
String regulationControl) {
this.preheatingAllowed = preheatingAllowed;
this.coolingAllowed = coolingAllowed;
this.regulationControl = regulationControl;
}
}
Loading

0 comments on commit 9d6d4ec

Please sign in to comment.