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.avmfritz.internal.hardware.callbacks;
15 import static org.eclipse.jetty.http.HttpMethod.GET;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.avmfritz.internal.hardware.FritzAhaWebInterface;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * Callback implementation for updating hue, saturation and duration. Supports reauthorization
25 * @author Christoph Weitkamp - Initial contribution
28 public class FritzAhaSetColorCallback extends FritzAhaReauthCallback {
30 private static final String WEBSERVICE_SET_COLOR_COMMAND = "switchcmd=setcolor";
31 private static final String WEBSERVICE_SET_UNMAPPED_COLOR_COMMAND = "switchcmd=setunmappedcolor";
33 private final Logger logger = LoggerFactory.getLogger(FritzAhaSetColorCallback.class);
35 private final String ain;
40 * @param webIface Interface to FRITZ!Box
41 * @param ain AIN of the device that should be switched
43 * @param saturation New saturation
44 * @param duration Duration of the change in 100ms. 0 immediately.
46 public FritzAhaSetColorCallback(FritzAhaWebInterface webIface, String ain, int hue, int saturation, int duration) {
47 this(webIface, ain, hue, saturation, duration, true);
53 * @param webIface Interface to FRITZ!Box
54 * @param ain AIN of the device that should be switched
56 * @param saturation New saturation
57 * @param duration Duration of the change in 100ms. 0 immediately.
58 * @param mapped Use mapped or unmapped color command
60 public FritzAhaSetColorCallback(FritzAhaWebInterface webIface, String ain, int hue, int saturation, int duration,
62 super(WEBSERVICE_PATH,
63 mapped ? WEBSERVICE_SET_COLOR_COMMAND
64 : WEBSERVICE_SET_UNMAPPED_COLOR_COMMAND + "&ain=" + ain + "&hue=" + hue + "&saturation="
65 + saturation + "&duration=" + duration,
71 public void execute(int status, String response) {
72 super.execute(status, response);
73 if (isValidRequest()) {
74 logger.debug("Received response '{}' for item '{}'", response, ain);