2 * Copyright (c) 2010-2021 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.apache.commons.lang.StringUtils;
18 import org.apache.commons.lang.math.NumberUtils;
19 import org.openhab.binding.homematic.internal.model.HmChannel;
20 import org.openhab.binding.homematic.internal.model.HmDatapointInfo;
21 import org.openhab.binding.homematic.internal.model.HmDevice;
22 import org.openhab.binding.homematic.internal.model.HmParamsetType;
25 * Parses a event received from a Homematic gateway.
27 * @author Gerhard Riegler - Initial contribution
29 public class EventParser extends CommonRpcParser<Object[], HmDatapointInfo> {
33 public HmDatapointInfo parse(Object[] message) throws IOException {
36 String addressWithChannel = toString(message[1]);
37 if ("".equals(addressWithChannel)) {
38 address = HmDevice.ADDRESS_GATEWAY_EXTRAS;
39 channel = HmChannel.CHANNEL_NUMBER_VARIABLE;
41 String[] configParts = StringUtils.trimToEmpty(addressWithChannel).split(":");
42 address = getSanitizedAddress(configParts[0]);
43 if (configParts.length > 1) {
44 channel = NumberUtils.createInteger(configParts[1]);
48 String name = toString(message[2]);
51 return new HmDatapointInfo(address, HmParamsetType.VALUES, channel, name);
55 * Returns the value of the event.
57 public Object getValue() {