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.model;
15 import org.openhab.binding.paradoxalarm.internal.communication.IRequest;
16 import org.openhab.binding.paradoxalarm.internal.communication.messages.partition.PartitionCommand;
17 import org.openhab.binding.paradoxalarm.internal.handlers.Commandable;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * The {@link Partition} Paradox partition.
23 * ID is always numeric (1-8 for Evo192)
25 * @author Konstantin Polihronov - Initial contribution
27 public class Partition extends Entity implements Commandable {
29 private final Logger logger = LoggerFactory.getLogger(Partition.class);
31 private PartitionState state = new PartitionState();
33 public Partition(ParadoxPanel panel, int id, String label) {
34 super(panel, id, label);
37 public PartitionState getState() {
41 public Partition setState(PartitionState state) {
43 logger.debug("Partition {} main state:\t{}", getLabel(), getState().getMainState());
44 if (logger.isTraceEnabled()) {
45 logger.trace("Partition {} detailed state:\t{}", getLabel(), getState().getDetailedState());
46 logger.trace("Partition {} full state dump:\t{}", getLabel(), getState());
52 public void handleCommand(String command) {
53 PartitionCommand partitionCommand = PartitionCommand.parse(command);
54 if (partitionCommand == null) {
55 logger.debug("Command {} is parsed to null. Skipping it", command);
59 logger.debug("Submitting command={} for partition=[{}]", partitionCommand, this);
60 IRequest request = partitionCommand.getRequest(getId());
61 getPanel().getCommunicator().submitRequest(request);