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.lutron.internal.radiora;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lutron.internal.radiora.protocol.LEDMapFeedback;
18 import org.openhab.binding.lutron.internal.radiora.protocol.LocalZoneChangeFeedback;
19 import org.openhab.binding.lutron.internal.radiora.protocol.RadioRAFeedback;
20 import org.openhab.binding.lutron.internal.radiora.protocol.ZoneMapFeedback;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * This class handles decoding message types from RadioRA
27 * @author Jeff Lauterbach - Initial Contribution
31 public class RS232MessageParser {
33 private final Logger logger = LoggerFactory.getLogger(RS232MessageParser.class);
35 public @Nullable RadioRAFeedback parse(String msg) {
36 String prefix = parsePrefix(msg);
40 return new LEDMapFeedback(msg);
42 return new LocalZoneChangeFeedback(msg);
44 return new ZoneMapFeedback(msg);
46 // No action to take when this message is received but handle
47 // it to prevent the the default log statement from occurring.
51 logger.debug("Unhandled msg received from RS232 [{}]", msg);
58 protected String parsePrefix(String msg) {
59 String[] arr = msg.split(",");
61 logger.debug("Unexpected msg received from RS232 [{}]", msg);