]> git.basschouten.com Git - openhab-addons.git/blob
ca1662dccf574be9dd76d855954c154e10606daa
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.powermax.internal.message;
14
15 import org.openhab.binding.powermax.internal.state.PowermaxState;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 /**
20  * A class for DENIED message handling
21  *
22  * @author Laurent Garnier - Initial contribution
23  */
24 public class PowermaxDeniedMessage extends PowermaxBaseMessage {
25
26     private final Logger logger = LoggerFactory.getLogger(PowermaxDeniedMessage.class);
27
28     /**
29      * Constructor
30      *
31      * @param message
32      *            the received message as a buffer of bytes
33      */
34     public PowermaxDeniedMessage(byte[] message) {
35         super(message);
36     }
37
38     @Override
39     public PowermaxState handleMessage(PowermaxCommManager commManager) {
40         super.handleMessage(commManager);
41
42         if (commManager == null) {
43             return null;
44         }
45
46         PowermaxState updatedState = null;
47
48         PowermaxSendType lastSendType = commManager.getLastSendMsg().getSendType();
49         if (lastSendType == PowermaxSendType.EVENTLOG || lastSendType == PowermaxSendType.ARM
50                 || lastSendType == PowermaxSendType.BYPASS) {
51             logger.debug("Powermax alarm binding: invalid PIN code");
52         } else if (lastSendType == PowermaxSendType.DOWNLOAD) {
53             logger.debug("Powermax alarm binding: openHAB Powerlink not enrolled");
54             updatedState = commManager.createNewState();
55             updatedState.setPowerlinkMode(false);
56         }
57
58         return updatedState;
59     }
60 }