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.velux.internal.bridge.slip;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.velux.internal.bridge.common.SetHouseStatusMonitor;
17 import org.openhab.binding.velux.internal.bridge.slip.utils.KLF200Response;
18 import org.openhab.binding.velux.internal.bridge.slip.utils.Packet;
19 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.Command;
20 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.CommandNumber;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * Protocol specific bridge communication supported by the Velux bridge:
26 * <B>Modify HouseStatusMonitor</B>
28 * Common Message semantic: Communication with the bridge and (optionally) storing returned information within the class
31 * As 3rd level class it defines informations how to send query and receive answer through the
32 * {@link org.openhab.binding.velux.internal.bridge.VeluxBridgeProvider VeluxBridgeProvider}
33 * as described by the interface {@link org.openhab.binding.velux.internal.bridge.slip.SlipBridgeCommunicationProtocol
34 * SlipBridgeCommunicationProtocol}.
36 * Methods in addition to the mentioned interface:
38 * <LI>{@link #serviceActivation} to define the new service activation state.</LI>
41 * @see SetHouseStatusMonitor
42 * @see SlipBridgeCommunicationProtocol
44 * @author Guenther Schreiner - Initial contribution.
47 class SCsetHouseStatusMonitor extends SetHouseStatusMonitor implements SlipBridgeCommunicationProtocol {
48 private final Logger logger = LoggerFactory.getLogger(SCsetHouseStatusMonitor.class);
50 private static final String DESCRIPTION = "Modify HouseStatusMonitor";
53 * ===========================================================
54 * Message Content Parameters
57 private boolean activateService = false;
60 * ===========================================================
64 private byte[] requestData = new byte[0];
67 * ===========================================================
71 private boolean success = false;
72 private boolean finished = false;
75 * ===========================================================
76 * Methods required for interface {@link BridgeCommunicationProtocol}.
80 public String name() {
85 public CommandNumber getRequestCommand() {
86 Command command = activateService ? Command.GW_HOUSE_STATUS_MONITOR_ENABLE_REQ
87 : Command.GW_HOUSE_STATUS_MONITOR_DISABLE_REQ;
90 logger.debug("getRequestCommand() returns {} ({}).", command.name(), command.getCommand());
91 return command.getCommand();
95 public byte[] getRequestDataAsArrayOfBytes() {
96 logger.debug("getRequestDataAsArrayOfBytes() data is {}.", new Packet(requestData).toString());
101 public void setResponse(short responseCommand, byte[] thisResponseData, boolean isSequentialEnforced) {
102 KLF200Response.introLogging(logger, responseCommand, thisResponseData);
105 switch (Command.get(responseCommand)) {
106 case GW_HOUSE_STATUS_MONITOR_ENABLE_CFM:
107 logger.trace("setResponse(): service enable confirmed by bridge.");
108 // returned enabled: successful if enable requested
109 success = activateService;
111 case GW_HOUSE_STATUS_MONITOR_DISABLE_CFM:
112 logger.trace("setResponse(): service disable confirmed by bridge.");
113 // returned disabled: successful if disable requested
114 success = !activateService;
118 KLF200Response.errorLogging(logger, responseCommand);
120 KLF200Response.outroLogging(logger, success, finished);
124 public boolean isCommunicationFinished() {
129 public boolean isCommunicationSuccessful() {
134 * ===========================================================
135 * Methods in addition to the interface {@link BridgeCommunicationProtocol}
136 * and the abstract class {@link SetHouseStatusMonitor}
140 public SetHouseStatusMonitor serviceActivation(boolean enableService) {
141 this.activateService = enableService;