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;
19 * Parses a listBidcosInterfaces message and extracts the type and gateway address.
21 * @author Gerhard Riegler - Initial contribution
23 public class ListBidcosInterfacesParser extends CommonRpcParser<Object[], ListBidcosInterfacesParser> {
25 private String gatewayAddress;
26 private String firmware;
27 private Integer dutyCycleRatio;
29 @SuppressWarnings("unchecked")
31 public ListBidcosInterfacesParser parse(Object[] message) throws IOException {
32 if (message != null && message.length > 0) {
33 message = (Object[]) message[0];
34 for (int i = 0; i < message.length; i++) {
35 Map<String, ?> mapMessage = (Map<String, ?>) message[i];
36 boolean isDefault = toBoolean(mapMessage.get("DEFAULT"));
39 type = toString(mapMessage.get("TYPE"));
40 firmware = toString(mapMessage.get("FIRMWARE_VERSION"));
41 gatewayAddress = getSanitizedAddress(mapMessage.get("ADDRESS"));
42 dutyCycleRatio = toInteger(mapMessage.get("DUTY_CYCLE"));
50 * Returns the parsed type.
52 public String getType() {
53 return type == null ? "" : type;
57 * Returns the parsed gateway address.
59 public String getGatewayAddress() {
60 return gatewayAddress;
64 * Returns the firmware version.
66 public String getFirmware() {
67 return firmware == null ? "" : firmware;
71 * Returns the duty cycle.
73 public Integer getDutyCycleRatio() {
74 return dutyCycleRatio;