]> git.basschouten.com Git - openhab-addons.git/blob
f199ff2ed485de628f20154e575acf282bb95d13
[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.enocean.internal.eep.A5_30;
14
15 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANNEL_SMOKEDETECTION;
16
17 import java.util.function.Function;
18
19 import org.openhab.binding.enocean.internal.messages.ERP1Message;
20 import org.openhab.core.config.core.Configuration;
21 import org.openhab.core.library.types.OnOffType;
22 import org.openhab.core.types.State;
23 import org.openhab.core.types.UnDefType;
24
25 /**
26  * EEP used for Smoke Detectors by Eltako
27  *
28  * @author Daniel Weber - Initial contribution
29  */
30 public class A5_30_03_ELTAKO extends A5_30_03 {
31
32     protected static final byte ALARM_ON = 0x0F;
33     protected static final byte ALARM_OFF = 0x1F;
34
35     public A5_30_03_ELTAKO() {
36         super();
37
38         this.supportsTeachInVariation3 = true;
39     }
40
41     public A5_30_03_ELTAKO(ERP1Message packet) {
42         super(packet);
43
44         this.supportsTeachInVariation3 = true;
45     }
46
47     @Override
48     protected State convertToStateImpl(String channelId, String channelTypeId,
49             Function<String, State> getCurrentStateFunc, Configuration config) {
50         byte db1 = getDB_1();
51         switch (channelId) {
52             case CHANNEL_SMOKEDETECTION:
53                 return db1 == ALARM_ON ? OnOffType.ON : (db1 == ALARM_OFF ? OnOffType.OFF : UnDefType.UNDEF);
54         }
55
56         return super.convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);
57     }
58 }