2 * Copyright (c) 2010-2024 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.radoneye.internal;
15 import static org.openhab.binding.bluetooth.radoneye.internal.RadoneyeBindingConstants.*;
18 import java.util.UUID;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.library.dimension.Density;
22 import org.openhab.core.library.types.QuantityType;
23 import org.openhab.core.thing.Thing;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * The {@link RadoneyeHandler} is responsible for handling commands, which are
29 * sent to one of the channels.
31 * @author Peter Obel - Initial contribution
34 public class RadoneyeHandler extends AbstractRadoneyeHandler {
36 private static final UUID SERVICE_UUID_V1 = UUID.fromString("00001523-1212-efde-1523-785feabcd123");
37 private static final UUID SERVICE_UUID_V2 = UUID.fromString("00001524-0000-1000-8000-00805f9b34fb");
38 private static final UUID TRIGGER_UID_V1 = UUID.fromString("00001524-1212-efde-1523-785feabcd123");
39 private static final UUID TRIGGER_UID_V2 = UUID.fromString("00001524-0000-1000-8000-00805f9b34fb");
40 private static final UUID DATA_UUID_V1 = UUID.fromString("00001525-1212-efde-1523-785feabcd123");
41 private static final UUID DATA_UUID_V2 = UUID.fromString("00001525-0000-1000-8000-00805f9b34fb");
42 private static final byte[] DATA_TRIGGER_V1 = new byte[] { 0x50 };
43 private static final byte[] DATA_TRIGGER_V2 = new byte[] { 0x50 };
45 public RadoneyeHandler(Thing thing) {
49 private final Logger logger = LoggerFactory.getLogger(RadoneyeHandler.class);
52 protected void updateChannels(int[] is) {
53 Map<String, Number> data;
55 data = RadoneyeDataParser.parseRd200Data(getFwVersion(), is);
56 logger.debug("Parsed data: {}", data);
57 Number radon = data.get(RadoneyeDataParser.RADON);
58 logger.debug("Parsed data radon number: {}", radon);
60 updateState(CHANNEL_ID_RADON, new QuantityType<Density>(radon, BECQUEREL_PER_CUBIC_METRE));
62 } catch (RadoneyeParserException e) {
63 logger.error("Failed to parse data received from Radoneye sensor: {}", e.getMessage());
68 protected UUID getDataUUID() {
69 int fwVersion = getFwVersion();
76 throw new UnsupportedOperationException("fwVersion: " + fwVersion + " is not implemented");
81 protected UUID getTriggerUUID() {
82 int fwVersion = getFwVersion();
85 return TRIGGER_UID_V1;
87 return TRIGGER_UID_V2;
89 throw new UnsupportedOperationException("fwVersion: " + fwVersion + " is not implemented");
94 protected byte[] getTriggerData() {
95 int fwVersion = getFwVersion();
98 return DATA_TRIGGER_V1;
100 return DATA_TRIGGER_V2;
102 throw new UnsupportedOperationException("fwVersion: " + fwVersion + " is not implemented");