]> git.basschouten.com Git - openhab-addons.git/blob
e866978231c37ad8eb55706308ce477698c6a0b5
[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 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 blind commands. Supports reauthorization
24  *
25  * @author Ulrich Mertin - Initial contribution
26  */
27 @NonNullByDefault
28 public class FritzAhaSetBlindTargetCallback extends FritzAhaReauthCallback {
29
30     private final Logger logger = LoggerFactory.getLogger(FritzAhaSetBlindTargetCallback.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 command Blind command to send
40      */
41     public FritzAhaSetBlindTargetCallback(FritzAhaWebInterface webIface, String ain, BlindCommand command) {
42         super(WEBSERVICE_PATH, "switchcmd=setblind&target=" + command.getTarget() + "&ain=" + ain, webIface, GET, 1);
43         this.ain = ain;
44     }
45
46     @Override
47     public void execute(int status, String response) {
48         super.execute(status, response);
49         if (isValidRequest()) {
50             logger.debug("Received response '{}' for item '{}'", response, ain);
51         }
52     }
53
54     public enum BlindCommand {
55         OPEN("open"),
56         CLOSE("close"),
57         STOP("stop");
58
59         private final String target;
60
61         private BlindCommand(final String target) {
62             this.target = target;
63         }
64
65         public String getTarget() {
66             return target;
67         }
68     }
69 }