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.plugwise.internal.protocol;
15 import static org.openhab.binding.plugwise.internal.protocol.field.MessageType.NODE_AVAILABLE;
17 import java.util.regex.Matcher;
18 import java.util.regex.Pattern;
20 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
23 * Node available messages are broadcasted by nodes that are not yet part of a network. They are currently unused
24 * because typically the network is configured using the Plugwise Source software, and never changed after.
26 * @author Wouter Born, Karel Goderis - Initial contribution
28 public class NodeAvailableMessage extends Message {
30 private static final Pattern PAYLOAD_PATTERN = Pattern.compile("(\\w{16})");
32 public NodeAvailableMessage(int sequenceNumber, String payload) {
33 super(NODE_AVAILABLE, sequenceNumber, payload);
37 protected void parsePayload() {
38 Matcher matcher = PAYLOAD_PATTERN.matcher(payload);
39 if (matcher.matches()) {
40 macAddress = new MACAddress(matcher.group(1));
42 throw new PlugwisePayloadMismatchException(NODE_AVAILABLE, PAYLOAD_PATTERN, payload);