diff --git a/bundles/org.openhab.binding.hydrawise/README.md b/bundles/org.openhab.binding.hydrawise/README.md index dfa54679cf444..876100d07332c 100644 --- a/bundles/org.openhab.binding.hydrawise/README.md +++ b/bundles/org.openhab.binding.hydrawise/README.md @@ -14,12 +14,13 @@ Changes made through this Thing type will be reflected in the Hydrawise mobile a #### Cloud Thing Supported Channel Groups -| channel group ID | -|---------------------------------------| -| [Zones](#Zone-Channel-Group) | -| [All Zones](#All-Zones-Channel-Group) | -| [Sensor](#Sensor-Channel-Group) | -| [Forecast](#Sensor-Channel-Group) | +| channel group ID | +|-----------------------------------------------| +| [Controller](#Cloud-Controller-Channel-Group) | +| [Zones](#Zone-Channel-Group) | +| [All Zones](#All-Zones-Channel-Group) | +| [Sensor](#Sensor-Channel-Group) | +| [Forecast](#Sensor-Channel-Group) | ### Local Thing @@ -70,6 +71,13 @@ Then copy the API key shown here: ### Channel Groups +#### Cloud Controller Channel Group + +| channel group ID | Description | +|------------------|----------------------------------| +| status | Status of controller | +| lastContact | Last contact time of controller | + #### Zone Channel Group Up to 36 total zones are supported per Local or Cloud thing @@ -114,6 +122,8 @@ A single all zone group are supported per Cloud or Local Thing ### Channels +Channels uses across zones, sensors and forecasts + | channel ID | type | Groups | description | Read Write | |-----------------|--------------------|----------------|---------------------------------------------|------------| | name | String | zone, sensor | Descriptive name | R | @@ -140,7 +150,25 @@ A single all zone group are supported per Cloud or Local Thing ## Full Example ``` -Group SprinklerZones +Group Sprinkler "Sprinkler" +Group SprinklerController "Controller" (Sprinkler) +Group SprinklerZones "Zones" (Sprinkler) +Group SprinklerSensors "Sensors" (Sprinkler) +Group SprinkerForecast "Forecast" (Sprinkler) + +String SprinkerControllerStatus "Status [%s]" (SprinklerController) {channel="hydrawise:cloud:home:controller#status"} +Number SprinkerControllerLastContact "Last Contact [%d]" (SprinklerController) {channel="hydrawise:cloud:home:controller#lastContact"} + +Switch SprinklerSensor1 "Sprinler Sensor" (SprinklerSensors) {channel="hydrawise:cloud:home:sensor1#active"} + +Group SprinkerForecastDay1 "Todays Forecast" (SprinkerForecast) +Number:Temperature SprinkerForecastDay1HiTemp "High Temp [%d]" (SprinkerForecastDay1) {channel="hydrawise:cloud:home:forecast1#temperaturehigh"} +Number:Temperature SprinkerForecastDay1LowTemp "Low Temp [%d]" (SprinkerForecastDay1) {channel="hydrawise:cloud:home:forecast1#temperaturelow"} +String SprinkerForecastDay1Conditions "Conditions [%s]" (SprinkerForecastDay1) {channel="hydrawise:cloud:home:forecast1#conditions"} +String SprinkerForecastDay1Day "Day [%s]" (SprinkerForecastDay1) {channel="hydrawise:cloud:home:forecast1#day"} +Number SprinkerForecastDay1Humidity "Humidity [%d%%]" (SprinkerForecastDay1) {channel="hydrawise:cloud:home:forecast1#humidity"} +Number:Speed SprinkerForecastDay1Wind "Wind [%s]" (SprinkerForecastDay1) {channel="hydrawise:cloud:home:forecast1#wind"} + Group SprinklerZone1 "1 Front Office Yard" (SprinklerZones) String SprinklerZone1Name "1 Front Office Yard name" (SprinklerZone1) {channel="hydrawise:cloud:home:zone1#name"} Switch SprinklerZone1Run "1 Front Office Yard Run" (SprinklerZone1) {channel="hydrawise:cloud:home:zone1#run"} diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseBindingConstants.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseBindingConstants.java index 309002526901d..f55b2be3bcbb5 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseBindingConstants.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseBindingConstants.java @@ -32,6 +32,9 @@ public class HydrawiseBindingConstants { public static final String BASE_IMAGE_URL = "https://app.hydrawise.com/config/images/"; + public static final String CHANNEL_GROUP_CONTROLLER = "controller"; + public static final String CHANNEL_CONTROLLER_LAST_CONTACT = "lastContact"; + public static final String CHANNEL_CONTROLLER_STATUS = "status"; public static final String CHANNEL_GROUP_ALLZONES = "allzones"; public static final String CHANNEL_ZONE_RUN_CUSTOM = "runcustom"; public static final String CHANNEL_ZONE_RUN = "run"; diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseCloudHandler.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseCloudHandler.java index eae56e06fe82b..da582985ff48b 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseCloudHandler.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/HydrawiseCloudHandler.java @@ -127,9 +127,10 @@ protected void configure() protected void pollController() throws HydrawiseConnectionException, HydrawiseAuthenticationException { List controllers = client.getCustomerDetails().controllers; Controller controller = getController(controllerId, controllers); - if (controller != null && !controller.online) { - throw new HydrawiseConnectionException("Controller is offline"); + if (controller == null) { + throw new HydrawiseConnectionException("Controller is offline or missing"); } + updateController(controller); StatusScheduleResponse status = client.getStatusSchedule(controllerId); updateSensors(status); updateForecast(status); @@ -179,6 +180,12 @@ protected void sendStopAllCommand() client.stopAllRelays(controllerId); } + private void updateController(Controller controller) { + updateGroupState(CHANNEL_GROUP_CONTROLLER, CHANNEL_CONTROLLER_LAST_CONTACT, + new DecimalType(controller.lastContact)); + updateGroupState(CHANNEL_GROUP_CONTROLLER, CHANNEL_CONTROLLER_STATUS, new StringType(controller.status)); + } + private void updateSensors(StatusScheduleResponse status) { status.sensors.forEach(sensor -> { String group = "sensor" + sensor.input; diff --git a/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/channel-types.xml index aeae5e87503bb..753e53c6a6551 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/channel-types.xml @@ -3,6 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> + + + Hydrawise cloud controller + + + + + @@ -27,7 +35,7 @@ - + Hydrawise sensor @@ -56,6 +64,23 @@ + + + Number + + Last contact time of a controller in seconds + + + + + String + + Status of the controller + + + + + String diff --git a/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/things.xml b/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/things.xml index 3b2e35fc485cf..b3e40324b49c9 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/things.xml +++ b/bundles/org.openhab.binding.hydrawise/src/main/resources/ESH-INF/thing/things.xml @@ -12,6 +12,16 @@ + + + + + + Controller + + + + Sensor 1 @@ -29,6 +39,8 @@ Sensor 4 + + Today's weather forecast @@ -46,8 +58,12 @@ Day 4 weather forecast + + + + Sprinkler Zone 1 @@ -383,6 +399,4 @@ - -