]> git.basschouten.com Git - openhab-addons.git/blob
76597503b0cb07ce604edf02953911e15dd773ff
[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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jetty.http.HttpMethod;
17 import org.openhab.binding.avmfritz.internal.hardware.FritzAhaWebInterface;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Callback implementation for updating heating modes
23  *
24  * @author Christoph Weitkamp - Initial contribution
25  */
26 @NonNullByDefault
27 public class FritzAhaSetHeatingModeCallback extends FritzAhaReauthCallback {
28
29     private final Logger logger = LoggerFactory.getLogger(FritzAhaSetHeatingModeCallback.class);
30
31     public static final String BOOST_COMMAND = "sethkrboost";
32     public static final String WINDOW_OPEN_COMMAND = "sethkrwindowopen";
33
34     private final String ain;
35
36     /**
37      * Constructor
38      *
39      * @param webInterface connection to FRITZ!Box
40      * @param ain AIN of the device
41      * @param command the mode to set or deactivate
42      * @param endTimestamp the end timestamp in seconds, maximum allowed value is now + 24h in the future, 0 to
43      *            deactivate the mode
44      */
45     public FritzAhaSetHeatingModeCallback(FritzAhaWebInterface webInterface, String ain, String command,
46             long endTimestamp) {
47         super(WEBSERVICE_PATH, String.format("switchcmd=%s&ain=%s&endtimestamp=%d", command, ain, endTimestamp),
48                 webInterface, HttpMethod.GET, 1);
49         this.ain = ain;
50     }
51
52     @Override
53     public void execute(int status, String response) {
54         super.execute(status, response);
55         if (isValidRequest()) {
56             logger.debug("Received response '{}' for item '{}'", response, ain);
57         }
58     }
59 }