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.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 String SERVICE_UUID = "00001523-1212-efde-1523-785feabcd123";
37 private static final String TRIGGER_UID = "00001524-1212-efde-1523-785feabcd123";
38 private static final String DATA_UUID = "00001525-1212-efde-1523-785feabcd123";
40 public RadoneyeHandler(Thing thing) {
44 private final Logger logger = LoggerFactory.getLogger(RadoneyeHandler.class);
46 private final UUID dataUuid = UUID.fromString(DATA_UUID);
47 private final UUID triggerUuid = UUID.fromString(TRIGGER_UID);
48 private final byte[] triggerData = new byte[] { 0x50 };
51 protected void updateChannels(int[] is) {
52 Map<String, Number> data;
54 data = RadoneyeDataParser.parseRd200Data(is);
55 logger.debug("Parsed data: {}", data);
56 Number radon = data.get(RadoneyeDataParser.RADON);
57 logger.debug("Parsed data radon number: {}", radon);
59 updateState(CHANNEL_ID_RADON, new QuantityType<Density>(radon, BECQUEREL_PER_CUBIC_METRE));
61 } catch (RadoneyeParserException e) {
62 logger.error("Failed to parse data received from Radoneye sensor: {}", e.getMessage());
67 protected UUID getDataUUID() {
72 protected UUID getTriggerUUID() {
77 protected byte[] getTriggerData() {