Skip to content

Commit

Permalink
[fineoffsetweatherstation] Implement new measurand free-stack-size
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Berger <andreas@berger-freelancer.com>
  • Loading branch information
Andy2003 committed Feb 26, 2024
1 parent d56c9e5 commit 4f55d3f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 deletions.
Expand Up @@ -19,15 +19,15 @@ Here is a product picture of how this Weather Station looks like:

![WH2650](doc/WH2650.png)

This binding works offline by [implementing the wire protocol](https://osswww.ecowitt.net/uploads/20220407/WN1900%20GW1000,1100%20WH2680,2650%20telenet%20v1.6.4.pdf) of the WiFi gateway device.
This binding works offline by [implementing the wire protocol](https://community.openhab.org/uploads/short-url/cuV8oOaCYHZhdm0hVJUN7hxMMfe.pdf) of the WiFi gateway device.

## Discussion

If you have any issues or feedback, please feel free to [get in touch via the community forum](https://community.openhab.org/t/fine-offset-weather-station-binding-discussion/134167)

## Supported Things

- `weatherstation`: A Fine Offset gateway device with the ThingTypeUID `fineoffsetweatherstation:weatherstation` which supports the [wire protocol](https://osswww.ecowitt.net/uploads/20220407/WN1900%20GW1000,1100%20WH2680,2650%20telenet%20v1.6.4.pdf) e.g.:
- `weatherstation`: A Fine Offset gateway device with the ThingTypeUID `fineoffsetweatherstation:weatherstation` which supports the [wire protocol](https://community.openhab.org/uploads/short-url/cuV8oOaCYHZhdm0hVJUN7hxMMfe.pdf) e.g.:
- HP2550
- HP3500
- GW1000
Expand Down Expand Up @@ -280,6 +280,7 @@ Valid sensors:
| piezo-rain-week | Number:Length | R | Piezo - Rainfall this Week |
| piezo-rain-month | Number:Length | R | Piezo - Rainfall this Month |
| piezo-rain-year | Number:Length | R | Piezo - Rainfall this Year |
| free-heap-size | Number:Dimensionless | R | Free Stack Size |

NOTE: Not every gateway provides all available data, even if they are displayed in the WS-View app.
Especially the channels `temperature-dew-point` or `temperature-wind-chill` are derived from other measured values.
Expand Down
Expand Up @@ -54,6 +54,8 @@ public class FineOffsetWeatherStationBindingConstants {
public static final ChannelTypeUID CHANNEL_TYPE_LIGHTNING_DISTANCE = new ChannelTypeUID(BINDING_ID,
"lightning-distance");

public static final ChannelTypeUID CHANNEL_TYPE_FREE_STACK_SIZE = new ChannelTypeUID(BINDING_ID, "free-stack-size");

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_GATEWAY, THING_TYPE_SENSOR);

public static final String SENSOR_CHANNEL_SIGNAL = "signal";
Expand Down
Expand Up @@ -12,6 +12,7 @@
*/
package org.openhab.binding.fineoffsetweatherstation.internal.domain;

import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_FREE_STACK_SIZE;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_MAX_WIND_SPEED;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_MOISTURE;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_UV_INDEX;
Expand Down Expand Up @@ -143,6 +144,9 @@ public enum Measurand {
// skip battery-level, since it is read via Command.CMD_READ_SENSOR_ID_NEW
new Skip(1)),

// This is for heap : the available stack top. If it is reducing, it means the stack is using up.
ITEM_HEAP_FREE("free-heap-size", 0x6c, "Free Heap Size", MeasureType.INTEGER, CHANNEL_TYPE_FREE_STACK_SIZE),

ITEM_SENSOR_CO2(0x70,
new MeasurandParser("sensor-co2-temperature", "Temperature (CO₂-Sensor)", MeasureType.TEMPERATURE),
new MeasurandParser("sensor-co2-humidity", "Humidity (CO₂-Sensor)", MeasureType.PERCENTAGE),
Expand Down
Expand Up @@ -122,6 +122,7 @@ public enum MeasureType {
(data, offset) -> Utils.toUInt16(data, offset) / 10.),

BYTE(1, null, (data, offset, context) -> new DecimalType(toUInt8(data[offset]))),
INTEGER(4, null, (data, offset, context) -> new DecimalType(toUInt32(data, offset))),

DATE_TIME2(6, null, (data, offset, context) -> new DateTimeType(
ZonedDateTime.ofInstant(Instant.ofEpochSecond(toUInt32(data, offset)), context.getZoneId())));
Expand Down
Expand Up @@ -30,6 +30,8 @@ channel-type.fineoffsetweatherstation.battery-voltage.label = Battery Voltage
channel-type.fineoffsetweatherstation.battery-voltage.description = The voltage of the battery
channel-type.fineoffsetweatherstation.co2.label = CO₂
channel-type.fineoffsetweatherstation.co2.description = Air Quality Indicator
channel-type.fineoffsetweatherstation.free-stack-size.description = The available stack size. If it is reducing, it means the stack is using up.
channel-type.fineoffsetweatherstation.free-stack-size.label = Free Stack Size
channel-type.fineoffsetweatherstation.humidity.label = Humidity
channel-type.fineoffsetweatherstation.illumination.label = Illumination
channel-type.fineoffsetweatherstation.lightning-counter.label = Lightning Counter
Expand Down Expand Up @@ -136,3 +138,4 @@ gateway.dynamic-channel.piezo-rain-day.label = Rain Day
gateway.dynamic-channel.piezo-rain-week.label = Rain Week
gateway.dynamic-channel.piezo-rain-month.label = Rain Month
gateway.dynamic-channel.piezo-rain-year.label = Rain Year
gateway.dynamic-channel.free-heap-size.label = Free Stack Size
Expand Up @@ -180,4 +180,10 @@
<label>Lightning Distance</label>
<state pattern="%.0f %unit%" readOnly="true"/>
</channel-type>

<channel-type id="free-stack-size">
<item-type>Number:Dimensionless</item-type>
<label>Free Stack Size</label>
<description>The available stack size. If it is reducing, it means the stack is using up.</description>
</channel-type>
</thing:thing-descriptions>
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2010-2024 Contributors to the openHAB project
*
* <p>

Check failure on line 3 in bundles/org.openhab.binding.fineoffsetweatherstation/src/test/java/org/openhab/binding/fineoffsetweatherstation/internal/service/FineOffsetDataParserTest.java

View workflow job for this annotation

GitHub Actions / Build (Java 17, ubuntu-22.04)

Header line doesn't match pattern ^ \*$
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* <p>
* 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
*
* <p>
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.fineoffsetweatherstation.internal.service;
Expand Down Expand Up @@ -123,6 +123,24 @@ void testLiveDataWH34AndWh45() {
new Tuple("sensor-co2-co2-24-hour-average", "891 ppm"));
}

@Test
void testLiveDataWithHeapFreeMeasurand() {
byte[] bytes = HexUtils.hexToBytes(
"FFFF27002F01010B062A0826C10926C1020011074D0A004C0B000C0C000D15000226C816006317011900136C0001FED864");
DebugDetails debugDetails = new DebugDetails(bytes, Command.CMD_GW1000_LIVEDATA, Protocol.DEFAULT);
List<MeasuredValue> data = new FineOffsetDataParser(Protocol.DEFAULT).getMeasuredValues(bytes,
new ConversionContext(ZoneOffset.UTC), debugDetails);
Assertions.assertThat(data)
.extracting(MeasuredValue::getChannelId, measuredValue -> measuredValue.getState().toString())
.containsExactly(new Tuple("temperature-indoor", "26.7 °C"), new Tuple("humidity-indoor", "42 %"),
new Tuple("pressure-absolute", "992.1 hPa"), new Tuple("pressure-relative", "992.1 hPa"),
new Tuple("temperature-outdoor", "1.7 °C"), new Tuple("humidity-outdoor", "77 %"),
new Tuple("direction-wind", "76 °"), new Tuple("speed-wind", "1.2 m/s"),
new Tuple("speed-gust", "1.3 m/s"), new Tuple("illumination", "14100 lx"),
new Tuple("irradiation-uv", "9.9 mW/m²"), new Tuple("uv-index", "1"),
new Tuple("wind-max-day", "1.9 m/s"), new Tuple("free-heap-size", "130776"));
}

@Test
void testLiveDataELV() {
byte[] data = HexUtils.hexToBytes(
Expand Down

0 comments on commit 4f55d3f

Please sign in to comment.