-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ondrej Pecta <opecta@gmail.com>
- Loading branch information
Showing
24 changed files
with
1,868 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This content is produced and maintained by the openHAB project. | ||
|
||
* Project home: https://www.openhab.org | ||
|
||
== Declared Project Licenses | ||
|
||
This program and the accompanying materials are made available under the terms | ||
of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
|
||
== Source Code | ||
|
||
https://github.com/openhab/openhab-addons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Orbit B-hyve Binding | ||
|
||
This is the binding for the [Orbit B-hyve](https://bhyve.orbitonline.com/) wi-fi sprinklers. | ||
|
||
## Supported Things | ||
|
||
This binding should support all the sprinklers which can be controlled by the Orbit B-hyve mobile application. | ||
So far only the [Orbit B-hyve 8-zone Indoor Timer](https://bhyve.orbitonline.com/indoor-timer/) has been confirmed working. (Hardware version WT24-0001) | ||
|
||
## Discovery | ||
|
||
This binding supports the auto discovery of the sprinklers bound to your Orbit B-hyve account. | ||
To start the discovery you need to create a bridge thing and enter valid credentials to your Orbit B-hyve cloud account. | ||
|
||
## Binding Configuration | ||
|
||
This binding does not require any configuration on the binding level. | ||
|
||
## Thing Configuration | ||
|
||
The bridge thing requires a manual configuration. You have to enter valid credentials to your Orbit B-hyve account, and you can also set the refresh time in seconds for polling data from the Orbit cloud. | ||
There is no user configuration related to sprinkler things. Sprinklers do need a configuration property _id_ identifying the device, but the only way how to retrieve it is to let the bridge to auto discover sprinklers. | ||
|
||
## Channels | ||
|
||
This binding automatically detects all zones and programs for each sprinkler and creates these dynamic channels: | ||
|
||
| channel | type | description | | ||
|------------------|--------|------------------------------------------------------------------| | ||
| zone_% | Switch | This channel controls the manual zone watering (ON/OFF) | | ||
| program_% | Switch | This channel controls the manual program watering (ON/OFF) | | ||
| enable_program_% | Switch | This channel controls the automatic program scheduling (ON/OFF) | | ||
|
||
Beside the dynamic channels each sprinkler thing provides these standard channels: | ||
|
||
| channel | type | description | | ||
|----------------|----------|--------------------------------------------------------------------| | ||
| mode | String | This channel represents the mode of sprinkler device (auto/manual) | | ||
| next_start | DateTime | This channel represents the start time of the next watering | | ||
| rain_delay | Number | This channel manages the current rain delay in hours | | ||
| watering_time | Number | This channel manages the manual zone watering time in minutes | | ||
| control | Switch | This channel controls the sprinkler (ON/OFF) | | ||
| smart_watering | Switch | This channel controls the smart watering (ON/OFF) | | ||
| control | String | This channel manages the manual zone watering time in minutes | | ||
|
||
|
||
## Full Example | ||
|
||
_*.things example_ | ||
|
||
``` | ||
Bridge orbitbhyve:bridge:mybridge "Orbit Bridge" [ email="your@ema.il", password="yourPass", refresh=30 ] { | ||
Thing sprinkler indoor_timer "Sprinkler" [ id="4cab55704e0d7ddf98c1cc37" ] | ||
} | ||
``` | ||
|
||
_*.items example_ | ||
|
||
``` | ||
Switch IrrigationControl "Irrigation active" <bhyve> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:control" } | ||
Switch IrrigationSmartWatering "Smart watering" <bhyve> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:smart_watering" } | ||
Switch Irrigation1 "Zone 1" <water> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:zone_1" } | ||
Switch Irrigation2 "Zone 2" <water> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:zone_2" } | ||
Switch Irrigation3 "Zone 3" <water> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:zone_3" } | ||
Switch Irrigation4 "Zone 4" <water> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:zone_4" } | ||
Switch IrrigationP1 "Run program A" <program> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:program_a" } | ||
Switch IrrigationP1Enable "Schedule program A" <program> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:enable_program_a" } | ||
String IrrigationMode "Irrigation mode [%s]" <water> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:mode" } | ||
Number IrrigationTime "Irrigation time [%d min]" <clock> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:watering_time" } | ||
Number IrrigationRainDelay "Rain delay [%d h]" <hourglass> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:rain_delay" } | ||
DateTime IrrigationNextStart "Next start A [%1$td.%1$tm.%1$tY %1$tR]" <clock> (Out_Irrigation) { channel="orbitbhyve:sprinkler:mybridge:indoor_timer:next_start" } | ||
``` | ||
|
||
_*.sitemap example_ | ||
|
||
``` | ||
Switch item=IrrigationControl | ||
Switch item=IrrigationSmartWatering | ||
Switch item=Irrigation1 | ||
Switch item=Irrigation2 | ||
Switch item=Irrigation3 | ||
Switch item=Irrigation4 | ||
Setpoint item=IrrigationTime minValue=1 maxValue=240 step=1 | ||
Switch item=IrrigationP1 | ||
Switch item=IrrigationP1Enable | ||
Text item=IrrigationMode | ||
Text item=IrrigationRainDelay | ||
Switch item=IrrigationRainDelay mappings=[0="OFF", 24="24", 48="48", 72="72"] | ||
Text item=IrrigationNextStart visibility=[IrrigationP1Enable==ON] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.openhab.addons.bundles</groupId> | ||
<artifactId>org.openhab.addons.reactor.bundles</artifactId> | ||
<version>3.2.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>org.openhab.binding.orbitbhyve</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: OrbitBhyve Binding</name> | ||
|
||
</project> |
9 changes: 9 additions & 0 deletions
9
bundles/org.openhab.binding.orbitbhyve/src/main/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<features name="org.openhab.binding.orbitbhyve-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"> | ||
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository> | ||
|
||
<feature name="openhab-binding-orbitbhyve" description="OrbitBhyve Binding" version="${project.version}"> | ||
<feature>openhab-runtime-base</feature> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.orbitbhyve/${project.version}</bundle> | ||
</feature> | ||
</features> |
49 changes: 49 additions & 0 deletions
49
...yve/src/main/java/org/openhab/binding/orbitbhyve/internal/OrbitBhyveBindingConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.orbitbhyve.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.core.thing.ThingTypeUID; | ||
|
||
/** | ||
* The {@link OrbitBhyveBindingConstants} class defines common constants, which are | ||
* used across the whole binding. | ||
* | ||
* @author Ondrej Pecta - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class OrbitBhyveBindingConstants { | ||
|
||
public static final String BINDING_ID = "orbitbhyve"; | ||
|
||
// List of all Thing Type UIDs | ||
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge"); | ||
public static final ThingTypeUID THING_TYPE_SPRINKLER = new ThingTypeUID(BINDING_ID, "sprinkler"); | ||
|
||
// List of all Channel ids | ||
public static final String CHANNEL_CONTROL = "control"; | ||
public static final String CHANNEL_MODE = "mode"; | ||
public static final String CHANNEL_SMART_WATERING = "smart_watering"; | ||
public static final String CHANNEL_NEXT_START = "next_start"; | ||
public static final String CHANNEL_RAIN_DELAY = "rain_delay"; | ||
public static final String CHANNEL_WATERING_TIME = "watering_time"; | ||
|
||
// Constants | ||
public static final String AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"; | ||
public static final String BHYVE_API = "https://api.orbitbhyve.com/v1/"; | ||
public static final String BHYVE_SESSION = BHYVE_API + "session"; | ||
public static final String BHYVE_DEVICES = BHYVE_API + "devices"; | ||
public static final String BHYVE_PROGRAMS = BHYVE_API + "sprinkler_timer_programs"; | ||
public static final String BHYVE_WS_URL = "wss://api.orbitbhyve.com/v1/events"; | ||
public static final int BHYVE_TIMEOUT = 5; | ||
} |
31 changes: 31 additions & 0 deletions
31
...tbhyve/src/main/java/org/openhab/binding/orbitbhyve/internal/OrbitBhyveConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.orbitbhyve.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* The {@link OrbitBhyveConfiguration} class contains fields mapping thing configuration parameters. | ||
* | ||
* @author Ondrej Pecta - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class OrbitBhyveConfiguration { | ||
|
||
/** | ||
* Sample configuration parameter. Replace with your own. | ||
*/ | ||
public String email = ""; | ||
public String password = ""; | ||
public int refresh = 30; | ||
} |
87 changes: 87 additions & 0 deletions
87
...bhyve/src/main/java/org/openhab/binding/orbitbhyve/internal/OrbitBhyveHandlerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.orbitbhyve.internal; | ||
|
||
import static org.openhab.binding.orbitbhyve.internal.OrbitBhyveBindingConstants.THING_TYPE_BRIDGE; | ||
import static org.openhab.binding.orbitbhyve.internal.OrbitBhyveBindingConstants.THING_TYPE_SPRINKLER; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.jetty.client.HttpClient; | ||
import org.eclipse.jetty.websocket.client.WebSocketClient; | ||
import org.openhab.binding.orbitbhyve.internal.handler.OrbitBhyveBridgeHandler; | ||
import org.openhab.binding.orbitbhyve.internal.handler.OrbitBhyveSprinklerHandler; | ||
import org.openhab.core.io.net.http.HttpClientFactory; | ||
import org.openhab.core.io.net.http.WebSocketFactory; | ||
import org.openhab.core.thing.Bridge; | ||
import org.openhab.core.thing.Thing; | ||
import org.openhab.core.thing.ThingTypeUID; | ||
import org.openhab.core.thing.binding.BaseThingHandlerFactory; | ||
import org.openhab.core.thing.binding.ThingHandler; | ||
import org.openhab.core.thing.binding.ThingHandlerFactory; | ||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
|
||
/** | ||
* The {@link OrbitBhyveHandlerFactory} is responsible for creating things and thing | ||
* handlers. | ||
* | ||
* @author Ondrej Pecta - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
@Component(configurationPid = "binding.orbitbhyve", service = ThingHandlerFactory.class) | ||
public class OrbitBhyveHandlerFactory extends BaseThingHandlerFactory { | ||
|
||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>( | ||
Arrays.asList(THING_TYPE_BRIDGE, THING_TYPE_SPRINKLER)); | ||
|
||
/** | ||
* the shared http client | ||
*/ | ||
private @NonNullByDefault({}) HttpClient httpClient; | ||
|
||
/** | ||
* the shared web socket client | ||
*/ | ||
private @NonNullByDefault({}) WebSocketClient webSocketClient; | ||
|
||
@Activate | ||
public OrbitBhyveHandlerFactory(@Reference HttpClientFactory httpClientFactory, | ||
@Reference WebSocketFactory webSocketFactory) { | ||
this.httpClient = httpClientFactory.getCommonHttpClient(); | ||
this.webSocketClient = webSocketFactory.getCommonWebSocketClient(); | ||
} | ||
|
||
@Override | ||
public boolean supportsThingType(ThingTypeUID thingTypeUID) { | ||
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); | ||
} | ||
|
||
@Override | ||
protected @Nullable ThingHandler createHandler(Thing thing) { | ||
ThingTypeUID thingTypeUID = thing.getThingTypeUID(); | ||
|
||
if (THING_TYPE_BRIDGE.equals(thingTypeUID)) { | ||
return new OrbitBhyveBridgeHandler((Bridge) thing, httpClient, webSocketClient); | ||
} | ||
if (THING_TYPE_SPRINKLER.equals(thingTypeUID)) { | ||
return new OrbitBhyveSprinklerHandler(thing); | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.