diff --git a/bundles/org.openhab.binding.fineoffsetweatherstation/README.md b/bundles/org.openhab.binding.fineoffsetweatherstation/README.md index fa4bb744e67..7cc93307a58 100644 --- a/bundles/org.openhab.binding.fineoffsetweatherstation/README.md +++ b/bundles/org.openhab.binding.fineoffsetweatherstation/README.md @@ -19,7 +19,7 @@ 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 @@ -27,7 +27,7 @@ If you have any issues or feedback, please feel free to [get in touch via the co ## 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 @@ -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:DataAmount | R | Free Heap 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. diff --git a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/FineOffsetWeatherStationBindingConstants.java b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/FineOffsetWeatherStationBindingConstants.java index f9faff1c9c5..52f86726a6d 100644 --- a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/FineOffsetWeatherStationBindingConstants.java +++ b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/FineOffsetWeatherStationBindingConstants.java @@ -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_HEAP_SIZE = new ChannelTypeUID(BINDING_ID, "free-heap-size"); + public static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_GATEWAY, THING_TYPE_SENSOR); public static final String SENSOR_CHANNEL_SIGNAL = "signal"; diff --git a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/Measurand.java b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/Measurand.java index d520787d7bd..12d97a3baf0 100644 --- a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/Measurand.java +++ b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/Measurand.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.fineoffsetweatherstation.internal.domain; +import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_FREE_HEAP_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; @@ -131,9 +132,9 @@ public enum Measurand { LEAK_CHX("water-leak-channel", new int[] { 0x58, 0x59, 0x5A, 0x5B }, "Leak", MeasureType.WATER_LEAK_DETECTION), // `LIGHTNING` is the name in the spec, so we keep it here as it - LIGHTNING("lightning-distance", 0x60, "lightning distance 1~40KM", MeasureType.LIGHTNING_DISTANCE), + LIGHTNING("lightning-distance", 0x60, "Lightning distance 1~40KM", MeasureType.LIGHTNING_DISTANCE), - LIGHTNING_TIME("lightning-time", 0x61, "lightning happened time", MeasureType.LIGHTNING_TIME), + LIGHTNING_TIME("lightning-time", 0x61, "Lightning happened time", MeasureType.LIGHTNING_TIME), // `LIGHTNING_POWER` is the name in the spec, so we keep it here as it LIGHTNING_POWER("lightning-counter", 0x62, "lightning counter for the day", MeasureType.LIGHTNING_COUNTER), @@ -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.MEMORY, CHANNEL_TYPE_FREE_HEAP_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), diff --git a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/MeasureType.java b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/MeasureType.java index c5085977766..8a3fbc68550 100644 --- a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/MeasureType.java +++ b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/java/org/openhab/binding/fineoffsetweatherstation/internal/domain/MeasureType.java @@ -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]))), + MEMORY(Units.BYTE, 4, null, Utils::toUInt32), DATE_TIME2(6, null, (data, offset, context) -> new DateTimeType( ZonedDateTime.ofInstant(Instant.ofEpochSecond(toUInt32(data, offset)), context.getZoneId()))); diff --git a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/i18n/fineoffsetweatherstation.properties b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/i18n/fineoffsetweatherstation.properties index 63424679a6e..b7f032095b9 100644 --- a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/i18n/fineoffsetweatherstation.properties +++ b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/i18n/fineoffsetweatherstation.properties @@ -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-heap-size.description = The available heap size. If it is reducing, it means the heap is using up. +channel-type.fineoffsetweatherstation.free-heap-size.label = Free Heap Size channel-type.fineoffsetweatherstation.humidity.label = Humidity channel-type.fineoffsetweatherstation.illumination.label = Illumination channel-type.fineoffsetweatherstation.lightning-counter.label = Lightning Counter @@ -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 diff --git a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/thing/gateway.xml b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/thing/gateway.xml index 3b798ecf743..067475fe756 100644 --- a/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/thing/gateway.xml +++ b/bundles/org.openhab.binding.fineoffsetweatherstation/src/main/resources/OH-INF/thing/gateway.xml @@ -180,4 +180,11 @@ + + + Number:DataAmount + + The available heap size. If it is reducing, it means the heap is using up. + + diff --git a/bundles/org.openhab.binding.fineoffsetweatherstation/src/test/java/org/openhab/binding/fineoffsetweatherstation/internal/service/FineOffsetDataParserTest.java b/bundles/org.openhab.binding.fineoffsetweatherstation/src/test/java/org/openhab/binding/fineoffsetweatherstation/internal/service/FineOffsetDataParserTest.java index 0c550479f75..4ab4c236708 100644 --- a/bundles/org.openhab.binding.fineoffsetweatherstation/src/test/java/org/openhab/binding/fineoffsetweatherstation/internal/service/FineOffsetDataParserTest.java +++ b/bundles/org.openhab.binding.fineoffsetweatherstation/src/test/java/org/openhab/binding/fineoffsetweatherstation/internal/service/FineOffsetDataParserTest.java @@ -123,6 +123,24 @@ class FineOffsetDataParserTest { 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 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 B")); + } + @Test void testLiveDataELV() { byte[] data = HexUtils.hexToBytes(