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.homematic.internal.communicator.parser;
15 import java.io.IOException;
18 import org.openhab.binding.homematic.internal.model.HmChannel;
19 import org.openhab.binding.homematic.internal.model.HmDatapoint;
20 import org.openhab.binding.homematic.internal.model.HmDatapointInfo;
21 import org.openhab.binding.homematic.internal.model.HmInterface;
22 import org.openhab.binding.homematic.internal.model.HmParamsetType;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Parses a paramset message and extracts datapoint values.
29 * @author Gerhard Riegler - Initial contribution
31 public class GetParamsetParser extends CommonRpcParser<Object[], Void> {
32 private final Logger logger = LoggerFactory.getLogger(GetParamsetParser.class);
34 private HmChannel channel;
35 private HmParamsetType paramsetType;
37 public GetParamsetParser(HmChannel channel, HmParamsetType paramsetType) {
38 this.channel = channel;
39 this.paramsetType = paramsetType;
43 @SuppressWarnings("unchecked")
44 public Void parse(Object[] message) throws IOException {
45 if (message == null || message.length == 0 || !(message[0] instanceof Map)) {
49 Map<String, ?> mapMessage = (Map<String, ?>) message[0];
50 for (String dpName : mapMessage.keySet()) {
51 HmDatapointInfo dpInfo = new HmDatapointInfo(paramsetType, channel, dpName);
52 HmDatapoint dp = channel.getDatapoint(dpInfo);
54 dp.setValue(convertToType(dp, mapMessage.get(dpName)));
57 // should never happen, but in case ...
59 // suppress warning for this datapoint due wrong CCU metadata
60 String deviceType = channel.getDevice().getType();
61 boolean isHmSenMdirNextTrans = "NEXT_TRANSMISSION".equals(dpInfo.getName())
62 && (deviceType.startsWith("HM-Sen-MDIR-O") || deviceType.startsWith("HM-Sen-MDIR-WM55")
63 || deviceType.startsWith("HM-Sec-MDIR-2"));
64 if (!isHmSenMdirNextTrans) {
65 if (dpInfo.getParamsetType() == HmParamsetType.MASTER
66 && channel.getDevice().getHmInterface() == HmInterface.HMIP) {
67 // These data points can't currently be recognized and therefore can't be created
68 logger.debug("Can't set value for channel configuration datapoint '{}'", dpInfo);
70 logger.warn("Can't set value for datapoint '{}'", dpInfo);