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;
17 import org.openhab.binding.homematic.internal.model.HmChannel;
18 import org.openhab.binding.homematic.internal.model.HmDatapoint;
19 import org.openhab.binding.homematic.internal.model.HmDatapointInfo;
20 import org.openhab.binding.homematic.internal.model.TclScriptDataEntry;
21 import org.openhab.binding.homematic.internal.model.TclScriptDataList;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * Parses a TclRega script result containing datapoint values for a channel.
28 * @author Gerhard Riegler - Initial contribution
30 public class CcuValueParser extends CommonRpcParser<TclScriptDataList, Void> {
31 private final Logger logger = LoggerFactory.getLogger(CcuValueParser.class);
33 private HmChannel channel;
35 public CcuValueParser(HmChannel channel) {
36 this.channel = channel;
40 public Void parse(TclScriptDataList resultList) throws IOException {
41 if (resultList.getEntries() != null) {
42 for (TclScriptDataEntry entry : resultList.getEntries()) {
43 HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, entry.name);
44 HmDatapoint dp = channel.getDatapoint(dpInfo);
46 dp.setValue(convertToType(dp, entry.value));
49 // should never happen, but in case ...
50 logger.warn("Can't set value for datapoint '{}'", dpInfo);