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.mihome.internal.handler;
15 import static org.openhab.binding.mihome.internal.XiaomiGatewayBindingConstants.CHANNEL_DENSITY;
17 import java.util.HashMap;
20 import org.openhab.core.library.types.DecimalType;
21 import org.openhab.core.thing.Thing;
23 import com.google.gson.JsonObject;
26 * Handles the Xiaomi smoke sensor
28 * @author Dieter Schmidt - Initial contribution
30 public class XiaomiSensorSmokeHandler extends XiaomiSensorBaseAlarmHandler {
32 private static final Map<Integer, String> ALARM_STATUS_MAP = new HashMap<>();
34 private static final String DENSITY = "density";
37 ALARM_STATUS_MAP.put(0, "OK");
38 ALARM_STATUS_MAP.put(1, "Fire alarm");
39 ALARM_STATUS_MAP.put(2, "Analog alarm");
40 ALARM_STATUS_MAP.put(8, "Battery fault alarm");
41 ALARM_STATUS_MAP.put(64, "Sensitivity fault alarm");
42 ALARM_STATUS_MAP.put(32768, "I2C communication failure");
45 public XiaomiSensorSmokeHandler(Thing thing) {
50 void parseReport(JsonObject data) {
51 super.parseReport(data);
52 if (data.has(DENSITY)) {
53 Integer density = data.get(DENSITY).getAsInt();
54 updateState(CHANNEL_DENSITY, new DecimalType(density));