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_LEAK;
17 import org.openhab.core.library.types.OnOffType;
18 import org.openhab.core.thing.Thing;
20 import com.google.gson.JsonObject;
23 * Handles the Xiaomi water leak sensor
25 * @author Kuba Wolanin - Initial contribution
27 public class XiaomiSensorWaterHandler extends XiaomiSensorBaseHandler {
29 private static final String STATUS = "status";
30 private static final String LEAK = "leak";
33 void parseReport(JsonObject data) {
34 boolean leak = data.has(STATUS) && LEAK.equals(data.get(STATUS).getAsString());
37 updateState(CHANNEL_LEAK, OnOffType.ON);
39 updateState(CHANNEL_LEAK, OnOffType.OFF);
43 public XiaomiSensorWaterHandler(Thing thing) {