]> git.basschouten.com Git - openhab-addons.git/blob
7424d8d981e20e2bdecd4b73cd06b1b9823d96b2
[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 OmniAreaHandler} defines some methods that are used to
28  * interface with an OmniLink OmniPro Area. This by extension also defines the
29  * OmniPro 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 OmniAreaHandler extends AbstractAreaHandler {
36     private static final EnumSet<AreaAlarm> OMNI_ALARMS = EnumSet.of(BURGLARY, FIRE, GAS, AUXILIARY, FREEZE, WATER,
37             DURESS, TEMPERATURE);
38     public @Nullable String number;
39
40     public OmniAreaHandler(Thing thing) {
41         super(thing);
42     }
43
44     @Override
45     protected int getMode(ChannelUID channelUID) {
46         switch (channelUID.getId()) {
47             case CHANNEL_AREA_SECURITY_MODE_DISARM:
48                 return OmniLinkCmd.CMD_SECURITY_OMNI_DISARM.getNumber();
49             case CHANNEL_AREA_SECURITY_MODE_DAY:
50                 return OmniLinkCmd.CMD_SECURITY_OMNI_DAY_MODE.getNumber();
51             case CHANNEL_AREA_SECURITY_MODE_NIGHT:
52                 return OmniLinkCmd.CMD_SECURITY_OMNI_NIGHT_MODE.getNumber();
53             case CHANNEL_AREA_SECURITY_MODE_AWAY:
54                 return OmniLinkCmd.CMD_SECURITY_OMNI_AWAY_MODE.getNumber();
55             case CHANNEL_AREA_SECURITY_MODE_VACATION:
56                 return OmniLinkCmd.CMD_SECURITY_OMNI_VACATION_MODE.getNumber();
57             case CHANNEL_AREA_SECURITY_MODE_DAY_INSTANT:
58                 return OmniLinkCmd.CMD_SECURITY_OMNI_DAY_INSTANCE_MODE.getNumber();
59             case CHANNEL_AREA_SECURITY_MODE_NIGHT_DELAYED:
60                 return OmniLinkCmd.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE.getNumber();
61             default:
62                 throw new IllegalStateException("Unknown channel for area thing " + channelUID);
63         }
64     }
65
66     @Override
67     protected EnumSet<AreaAlarm> getAlarms() {
68         return OMNI_ALARMS;
69     }
70 }