]> git.basschouten.com Git - openhab-addons.git/blob
66dea6b7e5182066f83e498147fb3f96ab0b4bc6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.avmfritz.internal.hardware.callbacks;
14
15 import static org.eclipse.jetty.http.HttpMethod.GET;
16
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;
21
22 /**
23  * Callback implementation for updating hue, saturation and duration. Supports reauthorization
24  *
25  * @author Christoph Weitkamp - Initial contribution
26  */
27 @NonNullByDefault
28 public class FritzAhaSetColorCallback extends FritzAhaReauthCallback {
29
30     private final Logger logger = LoggerFactory.getLogger(FritzAhaSetColorCallback.class);
31
32     private final String ain;
33
34     /**
35      * Constructor
36      *
37      * @param webIface Interface to FRITZ!Box
38      * @param ain AIN of the device that should be switched
39      * @param hue New hue
40      * @param saturation New saturation
41      * @param duration Duration of the change in 100ms. 0 immediately.
42      */
43     public FritzAhaSetColorCallback(FritzAhaWebInterface webIface, String ain, int hue, int saturation, int duration) {
44         super(WEBSERVICE_PATH,
45                 "switchcmd=setcolor&ain=" + ain + "&hue=" + hue + "&saturation=" + saturation + "&duration=" + duration,
46                 webIface, GET, 1);
47         this.ain = ain;
48     }
49
50     @Override
51     public void execute(int status, String response) {
52         super.execute(status, response);
53         if (isValidRequest()) {
54             logger.debug("Received response '{}' for item '{}'", response, ain);
55         }
56     }
57 }