]> git.basschouten.com Git - openhab-addons.git/blob
c55f09fd9ddc51d8d6cb0a42b9aeb7471db50a04
[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.hue.internal.handler.sensors;
14
15 import static org.openhab.binding.hue.internal.HueBindingConstants.*;
16 import static org.openhab.binding.hue.internal.api.dto.clip1.FullSensor.STATE_PRESENCE;
17
18 import java.util.Map;
19 import java.util.Set;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.openhab.binding.hue.internal.api.dto.clip1.FullSensor;
23 import org.openhab.binding.hue.internal.api.dto.clip1.SensorConfigUpdate;
24 import org.openhab.binding.hue.internal.handler.HueSensorHandler;
25 import org.openhab.core.config.core.Configuration;
26 import org.openhab.core.library.types.OnOffType;
27 import org.openhab.core.thing.Thing;
28 import org.openhab.core.thing.ThingTypeUID;
29
30 /**
31  * Geofence Presence Sensor
32  *
33  * @author Christoph Weitkamp - Initial contribution
34  */
35 @NonNullByDefault
36 public class GeofencePresenceHandler extends HueSensorHandler {
37
38     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_GEOFENCE_SENSOR);
39
40     public GeofencePresenceHandler(Thing thing) {
41         super(thing);
42     }
43
44     @Override
45     protected SensorConfigUpdate doConfigurationUpdate(Map<String, Object> configurationParameters) {
46         return new SensorConfigUpdate();
47     }
48
49     @Override
50     protected void doSensorStateChanged(FullSensor sensor, Configuration config) {
51         Object presence = sensor.getState().get(STATE_PRESENCE);
52         if (presence != null) {
53             boolean value = Boolean.parseBoolean(String.valueOf(presence));
54             updateState(CHANNEL_PRESENCE, OnOffType.from(value));
55         }
56     }
57 }