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.innogysmarthome.internal.client.entity.action;
15 import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
18 * Special {@link Action} needed to set a state of a device.
20 * @author Oliver Kuhl - Initial contribution
22 public class StateActionSetter extends Action {
24 private static final String CONSTANT = "Constant";
27 * Constructs a new {@link StateActionSetter}.
29 * @param capabilityId String of the 32 character capability id
30 * @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_SWITCHACTUATOR} or
31 * {@link Capability#TYPE_VARIABLEACTUATOR}
32 * @param state the new state as boolean (true=on, false=off)
34 public StateActionSetter(String capabilityId, String capabilityType, boolean state) {
35 setType(ACTION_TYPE_SETSTATE);
36 setTargetCapabilityById(capabilityId);
37 final ActionParams params = new ActionParams();
39 if (Capability.TYPE_SWITCHACTUATOR.equals(capabilityType)) {
40 params.setOnState(new BooleanActionParam(CONSTANT, state));
41 } else if (Capability.TYPE_VARIABLEACTUATOR.equals(capabilityType)) {
42 params.setValue(new BooleanActionParam(CONSTANT, state));
43 } else if (Capability.TYPE_ALARMACTUATOR.equals(capabilityType)) {
44 params.setOnState(new BooleanActionParam(CONSTANT, state));
50 * Constructs a new {@link StateActionSetter}.
52 * @param capabilityId String of the 32 character capability id
53 * @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_THERMOSTATACTUATOR}
54 * @param newValue the new double value
56 public StateActionSetter(String capabilityId, String capabilityType, double newValue) {
57 setType(ACTION_TYPE_SETSTATE);
58 setTargetCapabilityById(capabilityId);
59 final ActionParams params = new ActionParams();
61 if (Capability.TYPE_THERMOSTATACTUATOR.equals(capabilityType)) {
62 params.setPointTemperature(new DoubleActionParam(CONSTANT, newValue));
68 * Constructs a new {@link StateActionSetter}.
70 * @param capabilityId String of the 32 character capability id
71 * @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_DIMMERACTUATOR}
72 * @param newValue the new int value
74 public StateActionSetter(String capabilityId, String capabilityType, int newValue) {
75 setType(ACTION_TYPE_SETSTATE);
76 setTargetCapabilityById(capabilityId);
77 final ActionParams params = new ActionParams();
79 if (Capability.TYPE_DIMMERACTUATOR.equals(capabilityType)) {
80 params.setDimLevel(new IntegerActionParam(CONSTANT, newValue));
81 } else if (Capability.TYPE_ROLLERSHUTTERACTUATOR.equals(capabilityType)) {
82 params.setShutterLevel(new IntegerActionParam(CONSTANT, newValue));
89 * Constructs a new {@link StateActionSetter}.
91 * @param capabilityId String of the 32 character capability id
92 * @param capabilityType the type of the {@link Capability}, {@link Capability#TYPE_THERMOSTATACTUATOR}
93 * @param newValue the new string value
95 public StateActionSetter(String capabilityId, String capabilityType, String newValue) {
96 setType(ACTION_TYPE_SETSTATE);
97 setTargetCapabilityById(capabilityId);
98 final ActionParams params = new ActionParams();
100 if (Capability.TYPE_THERMOSTATACTUATOR.equals(capabilityType)) {
101 params.setOperationMode(new StringActionParam(CONSTANT, newValue));