2 * Copyright (c) 2010-2021 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.powermax.internal.message;
15 import org.openhab.binding.powermax.internal.state.PowermaxState;
18 * A class for PANEL message handling
20 * @author Laurent Garnier - Initial contribution
22 public class PowermaxPanelMessage extends PowermaxBaseMessage {
28 * the received message as a buffer of bytes
30 public PowermaxPanelMessage(byte[] message) {
35 protected PowermaxState handleMessageInternal(PowermaxCommManager commManager) {
36 if (commManager == null) {
40 PowermaxState updatedState = commManager.createNewState();
42 byte[] message = getRawData();
43 int msgCnt = message[2] & 0x000000FF;
45 debug("Event count", msgCnt);
47 for (int i = 1; i <= msgCnt; i++) {
48 byte eventZone = message[2 + 2 * i];
49 byte logEvent = message[3 + 2 * i];
50 int eventType = logEvent & 0x0000007F;
51 String logEventStr = PowermaxMessageConstants.getSystemEventString(eventType);
52 String logUserStr = PowermaxMessageConstants.getZoneOrUserString(eventZone & 0x000000FF);
53 updatedState.setPanelStatus(logEventStr + " (" + logUserStr + ")");
55 debug("Event " + i + " zone code", eventZone, logUserStr);
56 debug("Event " + i + " event code", eventType, logEventStr);
60 PowermaxAlarmType alarmType = PowermaxAlarmType.fromCode(eventType);
61 alarmStatus = alarmType.getLabel();
62 } catch (IllegalArgumentException e) {
65 updatedState.setAlarmType(alarmStatus);
69 PowermaxTroubleType troubleType = PowermaxTroubleType.fromCode(eventType);
70 troubleStatus = troubleType.getLabel();
71 } catch (IllegalArgumentException e) {
72 troubleStatus = "None";
74 updatedState.setTroubleType(troubleStatus);
76 if (eventType == 0x60) {
78 updatedState.setDownloadSetupRequired(true);