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;
16 import java.util.Objects;
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.HmParamsetType;
21 import org.openhab.binding.homematic.internal.model.HmValueType;
24 * Parses a Homegear message with scripts and generates the scripts.
26 * @author Gerhard Riegler - Initial contribution
28 public class GetAllScriptsParser extends CommonRpcParser<Object[], Void> {
29 private HmChannel channel;
31 public GetAllScriptsParser(HmChannel channel) {
32 this.channel = channel;
36 public Void parse(Object[] message) throws IOException {
37 message = (Object[]) message[0];
38 for (int i = 0; i < message.length; i++) {
39 String scriptName = Objects.toString(message[i], "");
40 HmDatapoint dpScript = new HmDatapoint(scriptName, scriptName, HmValueType.BOOL, Boolean.FALSE, false,
41 HmParamsetType.VALUES);
42 dpScript.setInfo(scriptName);
43 channel.addDatapoint(dpScript);