2 * Copyright (c) 2010-2023 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.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.powermax.internal.state.PowermaxPanelType;
18 import org.openhab.binding.powermax.internal.state.PowermaxState;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * A class for INFO message handling
25 * @author Laurent Garnier - Initial contribution
28 public class PowermaxInfoMessage extends PowermaxBaseMessage {
30 private final Logger logger = LoggerFactory.getLogger(PowermaxInfoMessage.class);
36 * the received message as a buffer of bytes
38 public PowermaxInfoMessage(byte[] message) {
43 protected @Nullable PowermaxState handleMessageInternal(@Nullable PowermaxCommManager commManager) {
44 if (commManager == null) {
48 PowermaxState updatedState = commManager.createNewState();
50 byte[] message = getRawData();
51 byte panelTypeNr = message[7];
54 PowermaxPanelType panelType = null;
56 panelType = PowermaxPanelType.fromCode(panelTypeNr);
57 panelTypeStr = panelType.toString();
58 } catch (IllegalArgumentException e) {
60 panelTypeStr = "UNKNOWN";
63 debug("Panel type", panelTypeNr, panelTypeStr);
65 logger.debug("Reading panel settings");
66 updatedState.downloadMode.setValue(true);
67 commManager.sendMessage(PowermaxSendType.DL_PANELFW);
68 commManager.sendMessage(PowermaxSendType.DL_SERIAL);
69 commManager.sendMessage(PowermaxSendType.DL_ZONESTR);
70 commManager.sendSetTime();
71 if ((panelType != null) && panelType.isPowerMaster()) {
72 commManager.sendMessage(PowermaxSendType.DL_MR_SIRKEYZON);
74 commManager.sendMessage(PowermaxSendType.START);
75 commManager.sendMessage(PowermaxSendType.EXIT);