]> git.basschouten.com Git - openhab-addons.git/blob
b831739500e12c57b1a2dca17ce187f45dd90fd5
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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 java.math.BigDecimal;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.avmfritz.internal.hardware.FritzAhaWebInterface;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * Callback implementation for updating blind / levelpercentage commands. Supports reauthorization
26  *
27  * @author Ulrich Mertin - Initial contribution
28  */
29 @NonNullByDefault
30 public class FritzAhaSetLevelPercentageCallback extends FritzAhaReauthCallback {
31
32     private final Logger logger = LoggerFactory.getLogger(FritzAhaSetLevelPercentageCallback.class);
33
34     private final String ain;
35
36     /**
37      * Constructor
38      *
39      * @param webIface Interface to FRITZ!Box
40      * @param ain AIN of the device that should be switched
41      * @param levelPercentage Opening level percentage (0 ... 100)
42      */
43     public FritzAhaSetLevelPercentageCallback(FritzAhaWebInterface webIface, String ain, BigDecimal levelPercentage) {
44         super(WEBSERVICE_PATH, "switchcmd=setlevelpercentage&level=" + levelPercentage + "&ain=" + ain, webIface, GET,
45                 1);
46         this.ain = ain;
47     }
48
49     @Override
50     public void execute(int status, String response) {
51         super.execute(status, response);
52         if (isValidRequest()) {
53             logger.debug("Received response '{}' for item '{}'", response, ain);
54         }
55     }
56 }