]> git.basschouten.com Git - openhab-addons.git/blob
f54eeb942361fbc0fc70f8d9cc7af2a0b034e217
[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.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 import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
27
28 /**
29  * The {@link OmniAreaHandler} defines some methods that are used to
30  * interface with an OmniLink OmniPro Area. This by extension also defines the
31  * OmniPro Area thing that openHAB will be able to pick up and interface with.
32  *
33  * @author Craig Hamilton - Initial contribution
34  * @author Ethan Dye - openHAB3 rewrite
35  */
36 @NonNullByDefault
37 public class OmniAreaHandler extends AbstractAreaHandler {
38     private static final EnumSet<AreaAlarm> OMNI_ALARMS = EnumSet.of(BURGLARY, FIRE, GAS, AUXILIARY, FREEZE, WATER,
39             DURESS, TEMPERATURE);
40     public @Nullable String number;
41
42     public OmniAreaHandler(Thing thing) {
43         super(thing);
44     }
45
46     @Override
47     protected int getMode(ChannelUID channelUID) {
48         switch (channelUID.getId()) {
49             case CHANNEL_AREA_SECURITY_MODE_DISARM:
50                 return CommandMessage.CMD_SECURITY_OMNI_DISARM;
51             case CHANNEL_AREA_SECURITY_MODE_DAY:
52                 return CommandMessage.CMD_SECURITY_OMNI_DAY_MODE;
53             case CHANNEL_AREA_SECURITY_MODE_NIGHT:
54                 return CommandMessage.CMD_SECURITY_OMNI_NIGHT_MODE;
55             case CHANNEL_AREA_SECURITY_MODE_AWAY:
56                 return CommandMessage.CMD_SECURITY_OMNI_AWAY_MODE;
57             case CHANNEL_AREA_SECURITY_MODE_VACATION:
58                 return CommandMessage.CMD_SECURITY_OMNI_VACATION_MODE;
59             case CHANNEL_AREA_SECURITY_MODE_DAY_INSTANT:
60                 return CommandMessage.CMD_SECURITY_OMNI_DAY_INSTANT_MODE;
61             case CHANNEL_AREA_SECURITY_MODE_NIGHT_DELAYED:
62                 return CommandMessage.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE;
63             default:
64                 throw new IllegalStateException("Unknown channel for area thing " + channelUID);
65         }
66     }
67
68     @Override
69     protected EnumSet<AreaAlarm> getAlarms() {
70         return OMNI_ALARMS;
71     }
72 }