2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.easee.internal.command.charger;
15 import static org.openhab.binding.easee.internal.EaseeBindingConstants.COMMANDS_URL;
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.AbstractWriteCommand;
21 import org.openhab.binding.easee.internal.command.JsonResultProcessor;
22 import org.openhab.binding.easee.internal.handler.EaseeThingHandler;
23 import org.openhab.core.thing.Channel;
24 import org.openhab.core.types.Command;
27 * implements the command api call of the charger.
29 * @author Alexander Friese - initial contribution
32 public class SendCommand extends AbstractWriteCommand {
33 String url = COMMANDS_URL;
36 * general constructor.
38 * @param handler the ThingHandler which is responsible for the channel
39 * @param chargerId Id of the charger which is adressed by this command
40 * @param channel the channel that triggered this command
41 * @param command the command to be send
43 public SendCommand(EaseeThingHandler handler, String chargerId, Channel channel, Command command,
44 JsonResultProcessor resultProcessor) {
45 this(handler, channel, command, resultProcessor);
46 this.url = COMMANDS_URL.replaceAll("\\{id\\}", chargerId).replaceAll("\\{command\\}", getCommandValue());
50 * this constructor should only be used by other command implementations that inherit this class.
52 * @param handler the ThingHandler which is responsible for the channel
53 * @param channel the channel that triggered this command
54 * @param command the command to be send
56 SendCommand(EaseeThingHandler handler, Channel channel, Command command, JsonResultProcessor resultProcessor) {
57 super(handler, channel, command, RetryOnFailure.YES, ProcessFailureResponse.YES, resultProcessor);
61 protected Request prepareWriteRequest(Request requestToPrepare) {
62 requestToPrepare.method(HttpMethod.POST);
64 return requestToPrepare;
68 protected String getURL() {