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.paradoxalarm.internal.communication.messages.zone;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.paradoxalarm.internal.communication.IRequest;
18 import org.openhab.binding.paradoxalarm.internal.communication.RequestType;
19 import org.openhab.binding.paradoxalarm.internal.communication.ZoneCommandRequest;
20 import org.openhab.binding.paradoxalarm.internal.communication.messages.Command;
21 import org.openhab.binding.paradoxalarm.internal.communication.messages.HeaderMessageType;
22 import org.openhab.binding.paradoxalarm.internal.communication.messages.ParadoxIPPacket;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * @author Konstantin Polihronov - Initial contribution
30 public enum ZoneCommand implements Command {
34 private static final Logger LOGGER = LoggerFactory.getLogger(ZoneCommand.class);
38 ZoneCommand(int command) {
39 this.command = (byte) command;
42 public byte getCommand() {
46 public static @Nullable ZoneCommand parse(@Nullable String command) {
47 if (command == null) {
52 return ZoneCommand.valueOf(command);
53 } catch (IllegalArgumentException e) {
54 LOGGER.debug("Unable to parse command={}. Fallback to UNKNOWN.", command);
60 public IRequest getRequest(int zoneId) {
61 ZoneCommandPayload payload = new ZoneCommandPayload(zoneId, this);
62 ParadoxIPPacket packet = new ParadoxIPPacket(payload.getBytes(), false)
63 .setMessageType(HeaderMessageType.SERIAL_PASSTHRU_REQUEST);
64 return new ZoneCommandRequest(RequestType.ZONE_COMMAND, packet, null);