[opensprinkler] Improvements: Remove apache.commons, fix bugs and warnings (#9869)

* Fix: current channel would not get added.

Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Fix: online and offline now detect correctly.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Improve discovery.

Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Bug fixes.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Misc Improvements and log cleanup.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Make current sensor channel dynamically get removed if not supported.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* fix compiler warning.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* readme updates.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Shift refresh()


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Add RSSI and water flow meter count channels.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Change to flowSensorCount


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Fix bug


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Fix NPE on parsing jsReplies.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Add new programs channel.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Fix wrong api use.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Change to using max time if the time is null.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Add device withRepresentationProperty

Signed-off-by: Matthew Skinner <matt@pcmus.com>

* update readme


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Fix rain sensor not working in 219 firmware.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Spotless fixes.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* fix gson double up error.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Add more channels


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* refresh completed before bridge goes online.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Simplify.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Allow non default password to not stop discovery.

Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Add ignoresRain channel


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Simplify commands in station handler.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Add new rainDelay channel.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Make constants consistent.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Add categories.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Changes requested by FlorianSW

Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Stop catching and throwing new exp.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Create a state class.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Update bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/discovery/OpenSprinklerDiscoveryService.java

Signed-off-by: Matthew Skinner <matt@pcmus.com>

Co-authored-by: Connor Petty <mistercpp2000@gmail.com>

* Fix for EOF exception that stops polling with bad wifi.

Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Change signal strength over to 0-4 range


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Handle toUnit null returns.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Support discovery on subnets that are not /24


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* update readme for recent changes to signalStrength channel.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Fix code anal issue and readme.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Remove info logging.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* remove traces of old dependancy.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Changes for fwolter


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* support RSSI and rssi


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Update after new command sent.


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* improve delayedRefresh


Signed-off-by: Matthew Skinner <matt@pcmus.com>

* Remove supressWarnings


Signed-off-by: Matthew Skinner <matt@pcmus.com>

Co-authored-by: Connor Petty <mistercpp2000@gmail.com>
This commit is contained in:
Matthew Skinner
2021-07-11 17:40:29 +10:00
committed by GitHub
parent 1e8be24fce
commit 6fc24e4aa4
40 changed files with 1313 additions and 767 deletions

View File

@@ -1,31 +1,28 @@
# OpenSprinkler Binding
This binding allows allows basic control of the OpenSprinkler devices.
Stations can be controlled to be turned on or off and rain sensor state can be read.
This binding allows good and flexible control over your OpenSprinkler devices.
You can choose to manually start, stop or delay the stand alone watering programs that are stored and run fully from the OpenSprinkler device.
Alternatively you can setup openHAB rules to control everything in more depth by setting up multiple `station` things for each watering zone to gain more in depth control.
By using the internal programs and sensors of the OpenSprinkler device, it can remove the complexity of what happens to the watering if openHAB crashes, is rebooted, or drops out of WiFi range in the middle of your watering rules.
Mixing the two concepts can also be done, the choice is yours.
## Supported Bridges
* HTTP (`http`) - The http bridge allows to communicate with an OpenSprinkler device through the network
* `OpenSprinkler HTTP Bridge` is required to communicate with an OpenSprinkler device through the network and should be added first.
## Supported Things
* OpenSprinkler Station (`station`) - to control a single station of a device, e.g. to turn it on or off
* OpenSprinkler Device (`device`) - for getting device-specific infos, e.g. if rain was detected
* `OpenSprinkler Station` is for gaining advanced controls and status information over a single station (zone) of a device, e.g. to turn it on or off, or the time remaining.
* `OpenSprinkler Device` is for device-specific controls that usually apply to multiple stations or main unit sensors, e.g. if rain was detected.
Recommend that you first add a single `device` thing and then if you need the extra controls, add as many of the `station` things as you wish.
## Discovery
OpenSprinkler devices can be manually discovered by sending a request to every IP on the network.
Discovery needs to be run manually as this is a brute force method of finding devices that can saturate network or device available bandwidth.
OpenSprinkler devices can be discovered by the binding sending requests to every IP on your network.
Due to this method used, it is very slow at finding devices and can saturate network bandwidth.
## Thing Configuration
OpenSprinkler using the HTTP interface
```
Bridge opensprinkler:http:http [hostname="127.0.0.1", port=80, password="opendoor", refresh=60] {
Thing station 01 [stationIndex=1]
}
```
## Bridge ('http') Configuration
- hostname: Hostname or IP address of the OpenSprinkler HTTP API.
- port: Port the OpenSprinkler device is listening on. Usually 80.
@@ -36,42 +33,54 @@ Bridge opensprinkler:http:http [hostname="127.0.0.1", port=80, password="opendoo
### Station Thing Configuration
The `station` thing can be used with both bridge and has the following configuration properties:
The `station` thing must be used with a `http` bridge and has the following configuration properties:
- stationIndex: The index of the station to communicate with, starting with 0 for the first station
## Channels
The following channel is supported by the `station` thing.
The following channels are supported by the `station` thing.
| Channel Type ID | Item Type | | Description |
|--------------------|-------------|----|----------------------------------------------------------|
| stationState | Switch | RW | This channel indicates whether station 01 is on or off. |
| stationState | Switch | RW | This channel indicates whether the station is on or off. |
| remainingWaterTime | Number:Time | R | The time the station remains to be open. |
| nextDuration | Number:Time | RW | A configuration item, which time, if linked, will be |
| | | | used as the time the station will be kept open when |
| | | | switched on. It is advised to add persistence for items |
| | | | linked to this channel, the binding does not persist |
| | | | values of it. |
| nextDuration | Number:Time | RW | The amount of time that will be used to keep the station |
| | | | open when next manually switched on. If not set, this |
| | | | value will default to 18 hours which is the maximum time |
| | | | supported. |
| queued | Switch | RW | Indicates that the station is queued to be turned on. |
| | | | The channel cannot be turned on, only turning it off is |
| | | | supported (which removes the station from the queue). |
| ignoreRain | Switch | RW | This channel makes the station ignore the rain delay. |
When using the `nextDuration` channel, it is advised to setup persistence (e.g. MapDB) in order to persist the value through restarts.
The following is supported by the `device` thing, but only when connected using the http interface.
The following channels are supported by the `device` thing.
NOTE: Some channels will only show up if the hardware has the required sensor and is setup correctly.
| Channel Type ID | Item Type | | Description |
|-----------------|------------------------|----|------------------------------------------------------------------------------------|
| rainsensor | Switch | RO | This channel indicates whether rain is detected by the device or not. |
| currentDraw | Number:ElectricCurrent | RO | Shows the current draw of the device. If the device does not have sensors |
| | | | for this metric, the channel will not be available. |
| sensor2 | Switch | RO | This channel is for the second sensor (if your hardware supports it). |
| 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. |
| 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. |
| rainDelay | Number:Time | RW | Sets/Shows the amount of time (hours) that rain has caused programs to be delayed. |
## Example
## Textual Example
demo.Things:
demo.things:
```
Bridge opensprinkler:http:http [hostname="127.0.0.1", port=81, password="opendoor"] {