]> git.basschouten.com Git - openhab-addons.git/blob
f08356b280f24fe837fc581d64d03ba1adcc7333
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.fineoffsetweatherstation.internal.service;
14
15 import java.time.ZoneOffset;
16 import java.util.List;
17
18 import org.assertj.core.api.Assertions;
19 import org.assertj.core.groups.Tuple;
20 import org.bouncycastle.util.encoders.Hex;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.fineoffsetweatherstation.internal.domain.ConversionContext;
24 import org.openhab.binding.fineoffsetweatherstation.internal.domain.response.MeasuredValue;
25
26 /**
27  * @author Andreas Berger - Initial contribution
28  */
29 @NonNullByDefault
30 class FineOffsetDataParserTest {
31     private final FineOffsetDataParser parser = new FineOffsetDataParser();
32
33     @Test
34     void testLiveDataWH45() {
35         List<MeasuredValue> data = parser.getLiveData(Hex.decode(
36                 "FFFF2700510100D306280827EF0927EF020045074F0A00150B00000C0000150000000016000117001900000E0000100000110021120000002113000005850D00007000D12E0060005A005B005502AE028F0633"),
37                 new ConversionContext(ZoneOffset.UTC));
38         Assertions.assertThat(data)
39                 .extracting(MeasuredValue::getChannelId, measuredValue -> measuredValue.getState().toString())
40                 .containsExactly(new Tuple("temperature-indoor", "21.1 °C"), new Tuple("humidity-indoor", "40 %"),
41                         new Tuple("pressure-absolute", "1022.3 hPa"), new Tuple("pressure-relative", "1022.3 hPa"),
42                         new Tuple("temperature-outdoor", "6.9 °C"), new Tuple("humidity-outdoor", "79 %"),
43                         new Tuple("direction-wind", "21 °"), new Tuple("speed-wind", "0 m/s"),
44                         new Tuple("speed-gust", "0 m/s"), new Tuple("illumination", "0 lx"),
45                         new Tuple("irradiation-uv", "1 µW/cm²"), new Tuple("uv-index", "0"),
46                         new Tuple("wind-max-day", "0 m/s"), new Tuple("rain-rate", "0 mm/h"),
47                         new Tuple("rain-day", "0 mm"), new Tuple("rain-week", "3.3 mm"),
48                         new Tuple("rain-month", "3.3 mm"), new Tuple("rain-year", "141.3 mm"),
49                         new Tuple("rain-event", "0 mm"), new Tuple("sensor-co2-temperature", "20.9 °C"),
50                         new Tuple("sensor-co2-humidity", "46 %"), new Tuple("sensor-co2-pm10", "9.6 µg/m³"),
51                         new Tuple("sensor-co2-pm10-24-hour-average", "9 µg/m³"),
52                         new Tuple("sensor-co2-pm25", "9.1 µg/m³"),
53                         new Tuple("sensor-co2-pm25-24-hour-average", "8.5 µg/m³"),
54                         new Tuple("sensor-co2-co2", "686 ppm"), new Tuple("sensor-co2-co2-24-hour-average", "655 ppm"));
55     }
56 }