Skip to content

Commit 8f3eef6

Browse files
Skinahfwolter
andauthored
[ipobserver] Weather station binding, Initial contribution. (openhab#10567)
* Bulk updated to UOM. Signed-off-by: Matthew Skinner <[email protected]> * ipObserver creation Signed-off-by: Matthew Skinner <[email protected]> * Bulk updated to UOM. Signed-off-by: Matthew Skinner <[email protected]> * channel fixup for UOM. Signed-off-by: Matthew Skinner <[email protected]> * improve UOM. Signed-off-by: Matthew Skinner <[email protected]> * updates Signed-off-by: Matthew Skinner <[email protected]> * Battery ch fixed. Signed-off-by: Matthew Skinner <[email protected]> * Fix time channels. Signed-off-by: Matthew Skinner <[email protected]> * readme update and remove %unit% from rain channels. Signed-off-by: Matthew Skinner <[email protected]> * readme fixup. Signed-off-by: Matthew Skinner <[email protected]> * edit global files. Signed-off-by: Matthew Skinner <[email protected]> * Fix merge conflicts. Signed-off-by: Matthew Skinner <[email protected]> * fix up build issues. Signed-off-by: Matthew Skinner <[email protected]> * remove reboot channel. Signed-off-by: Matthew Skinner <[email protected]> * readme fixup. Signed-off-by: Matthew Skinner <[email protected]> * Rename channels to put kind first. Signed-off-by: Matthew Skinner <[email protected]> * update to build on latest main. Signed-off-by: Matthew Skinner <[email protected]> * Add support for outBatt1 Signed-off-by: Matthew Skinner <[email protected]> * Added auto discovery. Signed-off-by: Matthew Skinner <[email protected]> * add bundle to POM. Signed-off-by: Matthew Skinner <[email protected]> * newline added. Signed-off-by: Matthew Skinner <[email protected]> * Fix bug in discovery. Signed-off-by: Matthew Skinner <[email protected]> * Added tags Signed-off-by: Matthew Skinner <[email protected]> * update to 3.2.0-SNAPSHOT Signed-off-by: Matthew Skinner <[email protected]> * Update bundles/org.openhab.binding.ipobserver/src/main/resources/OH-INF/thing/thing-types.xml Signed-off-by: Matthew Skinner <[email protected]> Co-authored-by: Fabian Wolter <[email protected]> * Update bundles/org.openhab.binding.ipobserver/src/main/resources/OH-INF/thing/thing-types.xml Signed-off-by: Matthew Skinner <[email protected]> Co-authored-by: Fabian Wolter <[email protected]> * Clean up channels Signed-off-by: Matthew Skinner <[email protected]> * Update binding description. Signed-off-by: Matthew Skinner <[email protected]> * Fix jsoup suggestions. Signed-off-by: Matthew Skinner <[email protected]> * Update bundles/org.openhab.binding.ipobserver/src/main/java/org/openhab/binding/ipobserver/internal/IpObserverDiscoveryService.java Signed-off-by: Matthew Skinner <[email protected]> Co-authored-by: Fabian Wolter <[email protected]> * Update bundles/org.openhab.binding.ipobserver/src/main/resources/OH-INF/thing/thing-types.xml Signed-off-by: Matthew Skinner <[email protected]> Co-authored-by: Fabian Wolter <[email protected]> * Removed nullable. Signed-off-by: Matthew Skinner <[email protected]> * Improvements Signed-off-by: Matthew Skinner <[email protected]> * Fix compiler warnings Signed-off-by: Matthew Skinner <[email protected]> * Change to datetime Signed-off-by: Matthew Skinner <[email protected]> * change to use system channels. Signed-off-by: Matthew Skinner <[email protected]> * Move to Number:Intensity for solar Signed-off-by: Matthew Skinner <[email protected]> Co-authored-by: Fabian Wolter <[email protected]>
1 parent b4a7c43 commit 8f3eef6

File tree

15 files changed

+1084
-0
lines changed

15 files changed

+1084
-0
lines changed

Diff for: CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
/bundles/org.openhab.binding.insteon/ @robnielsen
129129
/bundles/org.openhab.binding.intesis/ @hmerk
130130
/bundles/org.openhab.binding.ipcamera/ @Skinah
131+
/bundles/org.openhab.binding.ipobserver/ @Skinah
131132
/bundles/org.openhab.binding.ipp/ @peuter
132133
/bundles/org.openhab.binding.irobot/ @Sonic-Amiga
133134
/bundles/org.openhab.binding.irtrans/ @kgoderis

Diff for: bom/openhab-addons/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,11 @@
626626
<artifactId>org.openhab.binding.ipcamera</artifactId>
627627
<version>${project.version}</version>
628628
</dependency>
629+
<dependency>
630+
<groupId>org.openhab.addons.bundles</groupId>
631+
<artifactId>org.openhab.binding.ipobserver</artifactId>
632+
<version>${project.version}</version>
633+
</dependency>
629634
<dependency>
630635
<groupId>org.openhab.addons.bundles</groupId>
631636
<artifactId>org.openhab.binding.ipp</artifactId>

Diff for: bundles/org.openhab.binding.ipobserver/NOTICE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This content is produced and maintained by the openHAB project.
2+
3+
* Project home: https://www.openhab.org
4+
5+
== Declared Project Licenses
6+
7+
This program and the accompanying materials are made available under the terms
8+
of the Eclipse Public License 2.0 which is available at
9+
https://www.eclipse.org/legal/epl-2.0/.
10+
11+
== Source Code
12+
13+
https://github.com/openhab/openhab-addons
14+
15+
== Third-party Content
16+
17+
jsoup
18+
* License: MIT License
19+
* Project: https://jsoup.org/
20+
* Source: https://github.com/jhy/jsoup

Diff for: bundles/org.openhab.binding.ipobserver/README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# IpObserver Binding
2+
3+
This binding is for any weather station that sends data to an IP Observer module.
4+
The weather stations that do this are made by a company in China called `Fine Offset` and then re-branded by many distribution companies around the world.
5+
Some of the brands include Aercus (433mhz), Ambient Weather (915mhz), Frogitt, Misol (433mhz), Pantech (433mhz), Sainlogic and many more.
6+
Whilst Ambient Weather has it own cloud based binding, the other brands will not work with that binding and Ambient Weather do not sell outside of the United States.
7+
This binding works fully offline and uses local scraping of the weather station data at 12 second resolution if you wish and is easy to setup.
8+
The other binding worth mentioning is the weather underground binding that allows the data to be intercepted on its way to WU, however many of the weather stations do not allow the redirection of the WU data and require you to know how to do redirections with a custom DNS server on your network.
9+
This binding is by far the easiest method and works for all the brands and will not stop the data still being sent to WU if you wish to do both at the same time.
10+
If your weather station came with a LCD screen instead of the IP Observer, you can add on the unit and the LCD screen will still work in parallel as the RF data is sent 1 way from the outdoor unit to the inside screens and IP Observer units.
11+
12+
## Supported Things
13+
14+
There is only one thing that can be added and is called `weatherstation`.
15+
16+
## Discovery
17+
18+
Auto discovery is supported and may take a while to complete as it scans all IP addresses on your network one by one.
19+
20+
## Thing Configuration
21+
22+
| Parameter | Required | Description |
23+
|-|-|-|
24+
| `address` | Y | Hostname or IP for the IP Observer |
25+
| `pollTime` | Y | Time in seconds between each Scan of the livedata.htm from the IP Observer |
26+
| `autoReboot` | Y | Time in milliseconds to wait for a reply before rebooting the IP Observer. A value of 0 disables this feature allowing you to manually trigger or use a rule to handle the reboots. |
27+
28+
## Channels
29+
30+
| channel | type | description |
31+
|-----------------------|-----------------------|------------------------------|
32+
| temperatureIndoor | Number:Temperature | The temperature indoors. |
33+
| temperatureOutdoor | Number:Temperature | The temperature outdoors. |
34+
| humidityIndoor | Number:Dimensionless | The humidity indoors. |
35+
| humidityOutdoor | Number:Dimensionless | The humidity outdoors. |
36+
| pressureAbsolute | Number:Pressure | The atmospheric pressure directly measured by the sensor. |
37+
| pressureRelative | Number:Pressure | The pressure adjusted to sea level to allow easier comparisons between different locations. |
38+
| windDirection | Number:Angle | The angle in degrees that the wind is coming from. |
39+
| windAverageSpeed | Number:Speed | The average wind speed. |
40+
| windSpeed | Number:Speed | The exact wind speed. Not all stations send this data. |
41+
| windGust | Number:Speed | The recent wind gust speed. |
42+
| windMaxGust | Number:Speed | The recent max wind gust speed. |
43+
| solarRadiation | Number:Intensity | Solar radiation. |
44+
| uv | Number | UV measurement. |
45+
| uvIndex | Number | The UV index. |
46+
| rainHourlyRate | Number:Length | The amount of rain that will fall, if it continues to fall at the same rate for an hour. Measures how heavy the current rain is falling. |
47+
| rainToday | Number:Length | Amount of rain since 12:00am. |
48+
| rainForWeek | Number:Length | Amount of rain for the week. |
49+
| rainForMonth | Number:Length | Amount of rain for the month. |
50+
| rainForYear | Number:Length | Amount of rain for the year. |
51+
| batteryIndoor | Switch | Battery status, ON if battery is low. |
52+
| batteryOutdoor | Switch | Battery status, OFF if battery is normal. |
53+
| responseTime | Number:Time | How long it took the weather station to reply to a request for the live data. |
54+
| lastUpdatedTime | DateTime | The time scraped from the weather station when it last read the sensors. |

Diff for: bundles/org.openhab.binding.ipobserver/pom.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.openhab.addons.bundles</groupId>
9+
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
10+
<version>3.2.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>org.openhab.binding.ipobserver</artifactId>
14+
15+
<name>openHAB Add-ons :: Bundles :: IpObserver Binding</name>
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.jsoup</groupId>
19+
<artifactId>jsoup</artifactId>
20+
<version>1.8.3</version>
21+
<scope>provided</scope>
22+
</dependency>
23+
</dependencies>
24+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<features name="org.openhab.binding.ipobserver-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
3+
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
4+
<feature name="openhab-binding-ipobserver" description="IpObserver Binding" version="${project.version}">
5+
<feature>openhab-runtime-base</feature>
6+
<bundle dependency="true">mvn:org.jsoup/jsoup/1.8.3</bundle>
7+
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.ipobserver/${project.version}</bundle>
8+
</feature>
9+
</features>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright (c) 2010-2021 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.ipobserver.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
import org.openhab.core.thing.ThingTypeUID;
17+
18+
/**
19+
* The {@link IpObserverBindingConstants} class defines common constants, which are
20+
* used across the whole binding.
21+
*
22+
* @author Matthew Skinner - Initial contribution
23+
*/
24+
@NonNullByDefault
25+
public class IpObserverBindingConstants {
26+
public static final String BINDING_ID = "ipobserver";
27+
public static final String REBOOT_URL = "/msgreboot.htm";
28+
public static final String LIVE_DATA_URL = "/livedata.htm";
29+
public static final String STATION_SETTINGS_URL = "/station.htm";
30+
public static final int DISCOVERY_THREAD_POOL_SIZE = 15;
31+
32+
// List of all Thing Type UIDs
33+
public static final ThingTypeUID THING_WEATHER_STATION = new ThingTypeUID(BINDING_ID, "weatherstation");
34+
35+
// List of all Channel ids
36+
public static final String TEMP_INDOOR = "temperatureIndoor";
37+
public static final String TEMP_OUTDOOR = "temperatureOutdoor";
38+
public static final String INDOOR_HUMIDITY = "humidityIndoor";
39+
public static final String OUTDOOR_HUMIDITY = "humidityOutdoor";
40+
public static final String ABS_PRESSURE = "pressureAbsolute";
41+
public static final String REL_PRESSURE = "pressureRelative";
42+
public static final String WIND_DIRECTION = "windDirection";
43+
public static final String WIND_AVERAGE_SPEED = "windAverageSpeed";
44+
public static final String WIND_SPEED = "windSpeed";
45+
public static final String WIND_GUST = "windGust";
46+
public static final String WIND_MAX_GUST = "windMaxGust";
47+
public static final String SOLAR_RADIATION = "solarRadiation";
48+
public static final String UV = "uv";
49+
public static final String UV_INDEX = "uvIndex";
50+
public static final String HOURLY_RAIN_RATE = "rainHourlyRate";
51+
public static final String DAILY_RAIN = "rainToday";
52+
public static final String WEEKLY_RAIN = "rainForWeek";
53+
public static final String MONTHLY_RAIN = "rainForMonth";
54+
public static final String YEARLY_RAIN = "rainForYear";
55+
public static final String INDOOR_BATTERY = "batteryIndoor";
56+
public static final String OUTDOOR_BATTERY = "batteryOutdoor";
57+
public static final String RESPONSE_TIME = "responseTime";
58+
public static final String LAST_UPDATED_TIME = "lastUpdatedTime";
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2010-2021 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.ipobserver.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
17+
/**
18+
* The {@link IpObserverConfiguration} class contains fields mapping thing configuration parameters.
19+
*
20+
* @author Matthew Skinner - Initial contribution
21+
*/
22+
@NonNullByDefault
23+
public class IpObserverConfiguration {
24+
public String address = "";
25+
public int pollTime = 20;
26+
public int autoReboot = 2000;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright (c) 2010-2021 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.ipobserver.internal;
14+
15+
import static org.openhab.binding.ipobserver.internal.IpObserverBindingConstants.LIVE_DATA_URL;
16+
17+
import java.util.concurrent.ExecutionException;
18+
import java.util.concurrent.TimeUnit;
19+
import java.util.concurrent.TimeoutException;
20+
21+
import org.eclipse.jdt.annotation.NonNullByDefault;
22+
import org.eclipse.jetty.client.api.ContentResponse;
23+
import org.eclipse.jetty.client.api.Request;
24+
import org.eclipse.jetty.http.HttpHeader;
25+
import org.eclipse.jetty.http.HttpMethod;
26+
27+
/**
28+
* The {@link IpObserverDiscoveryJob} class allows auto discovery of
29+
* devices for a single IP address. This is used
30+
* for threading to make discovery faster.
31+
*
32+
* @author Matthew Skinner - Initial contribution
33+
*/
34+
@NonNullByDefault
35+
public class IpObserverDiscoveryJob implements Runnable {
36+
private IpObserverDiscoveryService discoveryClass;
37+
private String ipAddress;
38+
39+
public IpObserverDiscoveryJob(IpObserverDiscoveryService service, String ip) {
40+
this.discoveryClass = service;
41+
this.ipAddress = ip;
42+
}
43+
44+
@Override
45+
public void run() {
46+
if (isIpObserverDevice(this.ipAddress)) {
47+
discoveryClass.submitDiscoveryResults(this.ipAddress);
48+
}
49+
}
50+
51+
private boolean isIpObserverDevice(String ip) {
52+
Request request = discoveryClass.getHttpClient().newRequest("http://" + ip + LIVE_DATA_URL);
53+
request.method(HttpMethod.GET).timeout(5, TimeUnit.SECONDS).header(HttpHeader.ACCEPT_ENCODING, "gzip");
54+
ContentResponse contentResponse;
55+
try {
56+
contentResponse = request.send();
57+
if (contentResponse.getStatus() == 200 && contentResponse.getContentAsString().contains("livedata.htm")) {
58+
return true;
59+
}
60+
} catch (InterruptedException | TimeoutException | ExecutionException e) {
61+
}
62+
return false;
63+
}
64+
}

0 commit comments

Comments
 (0)