]> git.basschouten.com Git - openhab-addons.git/blob
e168a6c4e101ea75e2ffdcaa815c096af9553c5a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mihome.internal.handler;
14
15 import static org.openhab.binding.mihome.internal.XiaomiGatewayBindingConstants.CHANNEL_BUTTON;
16
17 import org.openhab.binding.mihome.internal.ChannelMapper;
18 import org.openhab.core.thing.Thing;
19
20 import com.google.gson.JsonObject;
21
22 /**
23  * Handles the Xiaomi smart switch device
24  *
25  * @author Patrick Boos - Initial contribution
26  */
27 public class XiaomiSensorSwitchHandler extends XiaomiSensorBaseHandler {
28
29     private static final String STATUS = "status";
30
31     public XiaomiSensorSwitchHandler(Thing thing) {
32         super(thing);
33     }
34
35     @Override
36     void parseReport(JsonObject data) {
37         if (data.has(STATUS)) {
38             triggerChannel(CHANNEL_BUTTON, ChannelMapper.getChannelEvent(data.get(STATUS).getAsString().toUpperCase()));
39         }
40     }
41 }