]> git.basschouten.com Git - openhab-addons.git/blob
044eeb919b78dc95fc8c2cf13c4ca8c8112f05d5
[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 applying templates.
24  *
25  * @author Christoph Weitkamp - Initial contribution
26  */
27 @NonNullByDefault
28 public class FritzAhaApplyTemplateCallback extends FritzAhaReauthCallback {
29
30     private final Logger logger = LoggerFactory.getLogger(FritzAhaApplyTemplateCallback.class);
31
32     private static final String WEBSERVICE_COMMAND = "switchcmd=applytemplate";
33
34     private final String ain;
35
36     /**
37      * Constructor
38      *
39      * @param webInterface web interface to FRITZ!Box
40      * @param ain AIN of the template that should be applied
41      */
42     public FritzAhaApplyTemplateCallback(FritzAhaWebInterface webInterface, String ain) {
43         super(WEBSERVICE_PATH, WEBSERVICE_COMMAND + "&ain=" + ain, webInterface, GET, 1);
44         this.ain = ain;
45     }
46
47     @Override
48     public void execute(int status, String response) {
49         super.execute(status, response);
50         if (isValidRequest()) {
51             logger.trace("Received response '{}' for item '{}'", response, ain);
52         }
53     }
54 }