Skip to content

Commit

Permalink
[fineoffsetweatherstation] adjustments after review
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 27, 2024
1 parent 32aa568 commit acde3bb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +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 |
| free-heap-memory | Number:DataAmount | 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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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 ChannelTypeUID CHANNEL_TYPE_FREE_HEAP_MEMORY = new ChannelTypeUID(BINDING_ID, "free-heap-memory");

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +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_FREE_HEAP_MEMORY;
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 @@ -132,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),
Expand All @@ -145,7 +145,7 @@ public enum Measurand {
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_HEAP_FREE("free-heap-memory", 0x6c, "Free Heap Memory", MeasureType.MEMORY, CHANNEL_TYPE_FREE_HEAP_MEMORY),

ITEM_SENSOR_CO2(0x70,
new MeasurandParser("sensor-co2-temperature", "Temperature (CO₂-Sensor)", MeasureType.TEMPERATURE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static javax.measure.MetricPrefix.KILO;
import static javax.measure.MetricPrefix.MILLI;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_CO2;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_FREE_HEAP_MEMORY;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_HUMIDITY;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_ILLUMINATION;
import static org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetWeatherStationBindingConstants.CHANNEL_TYPE_LIGHTNING_COUNTER;
Expand Down Expand Up @@ -122,7 +123,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))),
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())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +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.free-heap-memory.description = The available heap memory. If it is reducing, it means the heap is using up.
channel-type.fineoffsetweatherstation.free-heap-memory.label = Free Heap Memory
channel-type.fineoffsetweatherstation.humidity.label = Humidity
channel-type.fineoffsetweatherstation.illumination.label = Illumination
channel-type.fineoffsetweatherstation.lightning-counter.label = Lightning Counter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@
<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 id="free-heap-memory" advanced="true">
<item-type>Number:DataAmount</item-type>
<label>Free Heap Memory</label>
<description>The available heap memory. If it is reducing, it means the heap is using up.</description>
<state pattern="%.0f %unit%" readOnly="true"/>
</channel-type>
</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void testLiveDataWithHeapFreeMeasurand() {
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"));
new Tuple("wind-max-day", "1.9 m/s"), new Tuple("free-heap-memory", "130776 B"));
}

@Test
Expand Down

0 comments on commit acde3bb

Please sign in to comment.