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.HmDatapointInfo;
19 import org.openhab.binding.homematic.internal.model.HmDevice;
20 import org.openhab.binding.homematic.internal.model.HmParamsetType;
23 * Parses an event received from a Homematic gateway.
25 * @author Gerhard Riegler - Initial contribution
27 public class EventParser extends CommonRpcParser<Object[], HmDatapointInfo> {
31 public HmDatapointInfo parse(Object[] message) throws IOException {
34 String addressWithChannel = toString(message[1]);
35 if ("".equals(addressWithChannel)) {
36 address = HmDevice.ADDRESS_GATEWAY_EXTRAS;
37 channel = HmChannel.CHANNEL_NUMBER_VARIABLE;
39 String addrChannel = addressWithChannel == null ? "" : addressWithChannel.trim();
40 String[] configParts = addrChannel.split(":");
41 address = getSanitizedAddress(configParts[0]);
42 if (configParts.length > 1) {
43 channel = configParts[1] == null ? null : Integer.valueOf(configParts[1]);
47 String name = toString(message[2]);
50 return new HmDatapointInfo(address, HmParamsetType.VALUES, channel, name);
54 * Returns the value of the event.
56 public Object getValue() {