]> git.basschouten.com Git - openhab-addons.git/blob
e560e0939e435b0dc35a87337788f21e29c152e3
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.omnilink.internal.handler;
14
15 import static org.openhab.binding.omnilink.internal.AreaAlarm.*;
16 import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.*;
17
18 import java.util.EnumSet;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.binding.omnilink.internal.AreaAlarm;
23 import org.openhab.core.thing.ChannelUID;
24 import org.openhab.core.thing.Thing;
25
26 /**
27  * The {@link LuminaAreaHandler} defines some methods that are used to
28  * interface with an OmniLink Lumina Area. This by extension also defines the
29  * Lumina Area thing that openHAB will be able to pick up and interface with.
30  *
31  * @author Craig Hamilton - Initial contribution
32  * @author Ethan Dye - openHAB3 rewrite
33  */
34 @NonNullByDefault
35 public class LuminaAreaHandler extends AbstractAreaHandler {
36     private static final EnumSet<AreaAlarm> LUMINA_ALARMS = EnumSet.of(FREEZE, WATER, TEMPERATURE);
37     public @Nullable String number;
38
39     public LuminaAreaHandler(Thing thing) {
40         super(thing);
41     }
42
43     @Override
44     protected int getMode(ChannelUID channelUID) {
45         switch (channelUID.getId()) {
46             case CHANNEL_AREA_SECURITY_MODE_HOME:
47                 return OmniLinkCmd.CMD_SECURITY_LUMINA_HOME_MODE.getNumber();
48             case CHANNEL_AREA_SECURITY_MODE_SLEEP:
49                 return OmniLinkCmd.CMD_SECURITY_LUMINA_SLEEP_MODE.getNumber();
50             case CHANNEL_AREA_SECURITY_MODE_AWAY:
51                 return OmniLinkCmd.CMD_SECURITY_LUMINA_AWAY_MODE.getNumber();
52             case CHANNEL_AREA_SECURITY_MODE_VACATION:
53                 return OmniLinkCmd.CMD_SECURITY_LUMINA_VACATION_MODE.getNumber();
54             case CHANNEL_AREA_SECURITY_MODE_PARTY:
55                 return OmniLinkCmd.CMD_SECURITY_LUMINA_PARTY_MODE.getNumber();
56             case CHANNEL_AREA_SECURITY_MODE_SPECIAL:
57                 return OmniLinkCmd.CMD_SECURITY_LUMINA_SPECIAL_MODE.getNumber();
58             default:
59                 throw new IllegalStateException("Unknown channel for area thing " + channelUID);
60         }
61     }
62
63     @Override
64     protected EnumSet<AreaAlarm> getAlarms() {
65         return LUMINA_ALARMS;
66     }
67 }