From a950f19e6035b9bf77bd18daf9178524b59a39c7 Mon Sep 17 00:00:00 2001 From: Matthew Skinner Date: Sun, 10 Dec 2023 20:25:57 +1100 Subject: [PATCH] [opensprinkler] Fix Program names and add new features for firmware 2.2.0 (#15410) * Fix Program names are not parsed correctly in firmware 2.2.0 --------- Signed-off-by: Matthew Skinner --- .../README.md | 25 +++--- .../org.openhab.binding.opensprinkler/pom.xml | 1 - .../OpenSprinklerBindingConstants.java | 3 + .../internal/OpenSprinklerState.java | 3 + .../internal/api/OpenSprinklerApi.java | 30 +++++++ .../internal/api/OpenSprinklerApiFactory.java | 4 +- .../api/OpenSprinklerHttpApiV100.java | 19 +++++ .../api/OpenSprinklerHttpApiV219.java | 2 +- .../api/OpenSprinklerHttpApiV220.java | 78 +++++++++++++++++++ .../handler/OpenSprinklerDeviceHandler.java | 38 +++++++++ .../OH-INF/i18n/opensprinkler.properties | 15 ++++ .../resources/OH-INF/thing/thing-types.xml | 43 ++++++++++ .../resources/OH-INF/update/instructions.xml | 22 ++++++ 13 files changed, 269 insertions(+), 14 deletions(-) create mode 100644 bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/api/OpenSprinklerHttpApiV220.java create mode 100644 bundles/org.openhab.binding.opensprinkler/src/main/resources/OH-INF/update/instructions.xml diff --git a/bundles/org.openhab.binding.opensprinkler/README.md b/bundles/org.openhab.binding.opensprinkler/README.md index d85028989..03ca4c97a 100644 --- a/bundles/org.openhab.binding.opensprinkler/README.md +++ b/bundles/org.openhab.binding.opensprinkler/README.md @@ -61,22 +61,25 @@ NOTE: Some channels will only show up if the hardware has the required sensor an | Channel Type ID | Item Type | | Description | |-----------------|------------------------|----|------------------------------------------------------------------------------------| -| rainsensor | Switch | RO | This channel indicates whether rain is detected by the device or not. | -| sensor2 | Switch | RO | This channel is for the second sensor (if your hardware supports it). | +| cloudConnected | Switch | RO | If the device is fully connected to the OpenSprinkler cloud this will show as 'ON'.| | currentDraw | Number:ElectricCurrent | RO | Shows the current draw of the device. | -| waterlevel | Number:Dimensionless | RO | This channel shows the current water level in percent (0-250%). The water level is | -| | | | calculated based on the weather and influences the duration of the water programs. | -| signalStrength | Number | RO | Shows how strong the WiFi Signal is. | +| enablePrograms | Switch | RW | Allow programs to auto run. When OFF, manually started stations will still work. | | flowSensorCount | Number:Dimensionless | RO | Shows the number of pulses the optional water flow sensor has reported. | -| programs | String | RW | Displays a list of the programs that are setup in your OpenSprinkler and when | -| | | | selected will start that program for you. | -| stations | String | RW | Display a list of stations that can be run when selected to the length of time set | -| | | | in the `nextDuration` channel. | | nextDuration | Number:Time | RW | The time the station will open for when any stations are selected from the | | | | | `stations` channel. Defaults to 30 minutes if not set. | -| resetStations | Switch | RW | The ON command will stop all stations immediately, including those waiting to run. | -| enablePrograms | Switch | RW | Allow programs to auto run. When OFF, manually started stations will still work. | +| pausePrograms | Number:Time | RW | Sets/Shows the amount of time that programs will be paused for. | +| programs | String | RW | Displays a list of the programs that are setup in your OpenSprinkler and when | +| | | | selected will start that program for you. | | rainDelay | Number:Time | RW | Sets/Shows the amount of time (hours) that rain has caused programs to be delayed. | +| rainsensor | Switch | RO | This channel indicates whether rain is detected by the device or not. | +| resetStations | Switch | RW | The ON command will stop all stations immediately, including those waiting to run. | +| sensor2 | Switch | RO | This channel is for the second sensor (if your hardware supports it). | +| signalStrength | Number | RO | Shows how strong the WiFi Signal is. | +| stations | String | RW | Display a list of stations that can be run when selected to the length of time set | +| | | | in the `nextDuration` channel. | +| waterlevel | Number:Dimensionless | RO | This channel shows the current water level in percent (0-250%). The water level is | +| | | | calculated based on the weather and influences the duration of the water programs. | +| queuedZones | Number | RO | A count of how many zones are running and also waiting to run in the queue. | ## Textual Example diff --git a/bundles/org.openhab.binding.opensprinkler/pom.xml b/bundles/org.openhab.binding.opensprinkler/pom.xml index b77b0c4c2..cc96b1671 100644 --- a/bundles/org.openhab.binding.opensprinkler/pom.xml +++ b/bundles/org.openhab.binding.opensprinkler/pom.xml @@ -13,5 +13,4 @@ org.openhab.binding.opensprinkler openHAB Add-ons :: Bundles :: OpenSprinkler Binding - diff --git a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerBindingConstants.java b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerBindingConstants.java index c698e4ec2..d16fab814 100644 --- a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerBindingConstants.java +++ b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerBindingConstants.java @@ -82,4 +82,7 @@ public class OpenSprinklerBindingConstants { public static final String NEXT_DURATION = "nextDuration"; public static final String CHANNEL_IGNORE_RAIN = "ignoreRain"; public static final String CHANNEL_RAIN_DELAY = "rainDelay"; + public static final String CHANNEL_QUEUED_ZONES = "queuedZones"; + public static final String CHANNEL_CLOUD_CONNECTED = "cloudConnected"; + public static final String CHANNEL_PAUSE_PROGRAMS = "pausePrograms"; } diff --git a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerState.java b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerState.java index 7deed6cd6..f0804c831 100644 --- a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerState.java +++ b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/OpenSprinklerState.java @@ -63,6 +63,9 @@ public class OpenSprinklerState { public int rssi = 1; public int flcrt = -1; public int curr = -1; + public int pt = -1; + public int nq = -1; + public int otcs = -1; } public static class JnResponse { diff --git a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/api/OpenSprinklerApi.java b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/api/OpenSprinklerApi.java index 42df1e5b6..483275ac2 100644 --- a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/api/OpenSprinklerApi.java +++ b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/api/OpenSprinklerApi.java @@ -253,4 +253,34 @@ public interface OpenSprinklerApi { * @return {@code QuantityType