]> git.basschouten.com Git - openhab-addons.git/blob
0b2ee415bc4408bf310188f8fa02ef40da9ff11b
[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.F6_01;
14
15 import org.openhab.binding.enocean.internal.eep.Base._RPSMessage;
16 import org.openhab.binding.enocean.internal.messages.ERP1Message;
17 import org.openhab.core.config.core.Configuration;
18 import org.openhab.core.thing.CommonTriggerEvents;
19
20 /**
21  *
22  * @author Daniel Weber - Initial contribution
23  */
24 public class F6_01_01 extends _RPSMessage {
25
26     public F6_01_01() {
27         super();
28     }
29
30     public F6_01_01(ERP1Message packet) {
31         super(packet);
32     }
33
34     @Override
35     protected String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
36             Configuration config) {
37
38         return getBit(bytes[0], 4) ? CommonTriggerEvents.PRESSED : CommonTriggerEvents.RELEASED;
39     }
40
41     @Override
42     protected boolean validateData(byte[] bytes) {
43         return super.validateData(bytes) && !getBit(bytes[0], 7);
44     }
45
46     @Override
47     public boolean isValidForTeachIn() {
48         // just treat press as teach in, ignore release
49         return t21 && !nu && bytes[0] == 0x10;
50     }
51 }