2 * Copyright (c) 2010-2021 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.nikohomecontrol.internal.protocol.nhc2;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.nikohomecontrol.internal.protocol.NhcAction;
18 import org.openhab.binding.nikohomecontrol.internal.protocol.NikoHomeControlCommunication;
19 import org.openhab.binding.nikohomecontrol.internal.protocol.NikoHomeControlConstants.ActionType;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * The {@link NhcAction2} class represents the action Niko Home Control II communication object. It contains all fields
25 * representing a Niko Home Control action and has methods to trigger the action in Niko Home Control and receive action
28 * @author Mark Herwege - Initial Contribution
31 public class NhcAction2 extends NhcAction {
33 private final Logger logger = LoggerFactory.getLogger(NhcAction2.class);
35 private volatile boolean booleanState;
37 private String technology;
39 NhcAction2(String id, String name, String model, String technology, ActionType type, @Nullable String location,
40 NikoHomeControlCommunication nhcComm) {
41 super(id, name, type, location, nhcComm);
43 this.technology = technology;
47 * Get on/off state of action.
49 * true for on, false for off
51 * @return action on/off state
53 boolean booleanState() {
58 public int getState() {
59 return booleanState ? state : 0;
63 * Sets on/off state of action.
65 * @param state - boolean false for on, true for off
67 public void setBooleanState(boolean state) {
69 if (getType().equals(ActionType.DIMMER)) {
71 // only send stored brightness value if on
88 * Sets state of action. This version is used for Niko Home Control II.
90 * @param state - The allowed values depend on the action type.
91 * switch action: 0 or 100
92 * dimmer action: between 0 and 100
93 * rollershutter action: between 0 and 100
96 public void setState(int state) {
98 if (getType().equals(ActionType.DIMMER)) { // for dimmers, only send the update to the event
109 * Sends action to Niko Home Control. This version is used for Niko Home Control II, that has extra status options.
111 * @param command - The allowed values depend on the action type.
112 * switch action: On or Off
113 * dimmer action: between 0 and 100, On or Off
114 * rollershutter action: between 0 and 100, Up, Down or Stop
117 public void execute(String command) {
118 logger.debug("Niko Home Control: execute action {} of type {} for {}", command, type, id);
120 nhcComm.executeAction(id, command);
124 * @return model as returned from Niko Home Control
126 public String getModel() {
131 * @return technology as returned from Niko Home Control
133 public String getTechnology() {