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.handler.EaseeThingHandler;
22 import org.openhab.core.thing.Channel;
23 import org.openhab.core.types.Command;
26 * implements the command api call of the charger.
28 * @author Alexander Friese - initial contribution
31 public class SendCommand extends AbstractWriteCommand {
32 String url = COMMANDS_URL;
35 * general constructor.
37 * @param handler the ThingHandler which is responsible for the channel
38 * @param chargerId Id of the charger which is adressed by this command
39 * @param channel the channel that triggered this command
40 * @param command the command to be send
42 public SendCommand(EaseeThingHandler handler, String chargerId, Channel channel, Command command) {
43 this(handler, channel, command);
44 this.url = COMMANDS_URL.replaceAll("\\{id\\}", chargerId).replaceAll("\\{command\\}", getCommandValue());
48 * this constructor should only be used by other command implementations that inherit this class.
50 * @param handler the ThingHandler which is responsible for the channel
51 * @param channel the channel that triggered this command
52 * @param command the command to be send
54 SendCommand(EaseeThingHandler handler, Channel channel, Command command) {
55 super(handler, channel, command, RetryOnFailure.YES, ProcessFailureResponse.YES);
59 protected Request prepareWriteRequest(Request requestToPrepare) {
60 requestToPrepare.method(HttpMethod.POST);
62 return requestToPrepare;
66 protected String getURL() {