2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.bluetooth.airthings.internal;
15 import static org.openhab.binding.bluetooth.airthings.internal.AirthingsBindingConstants.*;
18 import java.util.UUID;
20 import javax.measure.quantity.Dimensionless;
21 import javax.measure.quantity.Temperature;
23 import org.eclipse.jdt.annotation.NonNullByDefault;
24 import org.openhab.core.library.types.QuantityType;
25 import org.openhab.core.library.unit.SIUnits;
26 import org.openhab.core.library.unit.Units;
27 import org.openhab.core.thing.Thing;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * The {@link AirthingsWaveMiniHandler} is responsible for handling commands, which are
33 * sent to one of the channels.
35 * @author Kai Kreuzer - Initial contribution
38 public class AirthingsWaveMiniHandler extends AbstractAirthingsHandler {
40 private static final String DATA_UUID = "b42e3b98-ade7-11e4-89d3-123b93f75cba";
42 public AirthingsWaveMiniHandler(Thing thing) {
46 private final Logger logger = LoggerFactory.getLogger(AirthingsWaveMiniHandler.class);
48 private final UUID uuid = UUID.fromString(DATA_UUID);
51 protected void updateChannels(int[] is) {
52 Map<String, Number> data;
54 data = AirthingsDataParser.parseWaveMiniData(is);
55 logger.debug("Parsed data: {}", data);
56 Number humidity = data.get(AirthingsDataParser.HUMIDITY);
57 if (humidity != null) {
58 updateState(CHANNEL_ID_HUMIDITY, new QuantityType<Dimensionless>(humidity, Units.PERCENT));
60 Number temperature = data.get(AirthingsDataParser.TEMPERATURE);
61 if (temperature != null) {
62 updateState(CHANNEL_ID_TEMPERATURE, new QuantityType<Temperature>(temperature, SIUnits.CELSIUS));
64 Number tvoc = data.get(AirthingsDataParser.TVOC);
66 updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, Units.PARTS_PER_BILLION));
68 } catch (AirthingsParserException e) {
69 logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());
74 protected UUID getDataUUID() {