]> git.basschouten.com Git - openhab-addons.git/blob
0aac16d32bf07a7eb2f14f8613d190409662c5ac
[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.ecovacs.internal.api.commands;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.ecovacs.internal.api.impl.ProtocolVersion;
18 import org.w3c.dom.Document;
19 import org.w3c.dom.Element;
20
21 import com.google.gson.JsonElement;
22 import com.google.gson.JsonObject;
23
24 /**
25  * @author Danny Baumann - Initial contribution
26  */
27 @NonNullByDefault
28 public class GoChargingCommand extends AbstractNoResponseCommand {
29     public GoChargingCommand() {
30         super();
31     }
32
33     @Override
34     public String getName(ProtocolVersion version) {
35         return version == ProtocolVersion.XML ? "Charge" : "charge";
36     }
37
38     @Override
39     protected void applyXmlPayload(Document doc, Element ctl) {
40         Element charge = doc.createElement("charge");
41         charge.setAttribute("type", "go");
42         ctl.appendChild(charge);
43     }
44
45     @Override
46     protected @Nullable JsonElement getJsonPayloadArgs(ProtocolVersion version) {
47         JsonObject args = new JsonObject();
48         args.addProperty("act", "go");
49         return args;
50     }
51 }