]> git.basschouten.com Git - openhab-addons.git/blob
8651ab97393967e3e6afaa1f96634f134c800c1b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.homematic.internal.communicator.parser;
14
15 import java.io.IOException;
16 import java.util.Objects;
17
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;
22
23 /**
24  * Parses a Homegear message with scripts and generates the scripts.
25  *
26  * @author Gerhard Riegler - Initial contribution
27  */
28 public class GetAllScriptsParser extends CommonRpcParser<Object[], Void> {
29     private HmChannel channel;
30
31     public GetAllScriptsParser(HmChannel channel) {
32         this.channel = channel;
33     }
34
35     @Override
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);
44         }
45         return null;
46     }
47 }