Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[orbitbhyve] Initial contribution #10426

Merged
merged 4 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
/bundles/org.openhab.binding.openweathermap/ @cweitkamp
/bundles/org.openhab.binding.openwebnet/ @mvalla
/bundles/org.openhab.binding.oppo/ @mlobstein
/bundles/org.openhab.binding.orbitbhyve/ @octa22
/bundles/org.openhab.binding.orvibo/ @tavalin
/bundles/org.openhab.binding.paradoxalarm/ @theater
/bundles/org.openhab.binding.pentair/ @jsjames
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,11 @@
<artifactId>org.openhab.binding.oppo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.orbitbhyve</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.orvibo</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.orbitbhyve/NOTICE
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
84 changes: 84 additions & 0 deletions bundles/org.openhab.binding.orbitbhyve/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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.

## 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 |
octa22 marked this conversation as resolved.
Show resolved Hide resolved
| watering_time | Number:Time | 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) |

## 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]
```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.orbitbhyve/pom.xml
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 :: Orbit B-hyve Binding</name>

</project>
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="Orbit B-hyve 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>
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;
}
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;
}
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));
octa22 marked this conversation as resolved.
Show resolved Hide resolved

/**
* the shared http client
*/
private HttpClient httpClient;

/**
* the shared web socket client
*/
private @NonNullByDefault({}) WebSocketClient webSocketClient;
octa22 marked this conversation as resolved.
Show resolved Hide resolved

@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;
}
}
Loading