]> git.basschouten.com Git - openhab-addons.git/blob
fe130c615ba6e14a8b47615d0c8054100280b51e
[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.easee.internal.command.circuit;
14
15 import static org.openhab.binding.easee.internal.EaseeBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jetty.client.api.Request;
19 import org.eclipse.jetty.http.HttpMethod;
20 import org.openhab.binding.easee.internal.command.AbstractCommand;
21 import org.openhab.binding.easee.internal.command.JsonResultProcessor;
22 import org.openhab.binding.easee.internal.handler.EaseeThingHandler;
23
24 /**
25  * implements the dynamicCurrent api call of the circuit.
26  *
27  * @author Alexander Friese - initial contribution
28  */
29 @NonNullByDefault
30 public class DynamicCircuitCurrent extends AbstractCommand {
31     private final String url;
32
33     public DynamicCircuitCurrent(EaseeThingHandler handler, String circuitId, JsonResultProcessor resultProcessor) {
34         super(handler, RetryOnFailure.NO, ProcessFailureResponse.YES, resultProcessor);
35         String siteId = handler.getBridgeConfiguration().getSiteId();
36         this.url = DYNAMIC_CIRCUIT_CURRENT_URL.replaceAll("\\{siteId\\}", siteId).replaceAll("\\{circuitId\\}",
37                 circuitId);
38     }
39
40     @Override
41     protected Request prepareRequest(Request requestToPrepare) {
42         requestToPrepare.method(HttpMethod.GET);
43         return requestToPrepare;
44     }
45
46     @Override
47     protected String getURL() {
48         return url;
49     }
50
51     @Override
52     protected String getChannelGroup() {
53         return CHANNEL_GROUP_CIRCUIT_DYNAMIC_CURRENT;
54     }
55 }