2 * Copyright (c) 2010-2024 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.automower.internal.things;
15 import java.util.EnumSet;
16 import java.util.HashMap;
18 import java.util.Optional;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.thing.ChannelUID;
24 * @author Markus Pfleger - Initial contribution
27 public enum AutomowerCommand {
28 START("Start", "mower#start"),
29 RESUME_SCHEDULE("ResumeSchedule", "mower#resume_schedule"),
30 PAUSE("Pause", "mower#pause"),
31 PARK("Park", "mower#park"),
32 PARK_UNTIL_NEXT_SCHEDULE("ParkUntilNextSchedule", "mower#park_until_next_schedule"),
33 PARK_UNTIL_FURTHER_NOTICE("ParkUntilFurtherNotice", "mower#park_until_further_notice");
35 private static final Map<String, AutomowerCommand> CHANNEL_TO_CMD_MAP = new HashMap<>();
38 EnumSet.allOf(AutomowerCommand.class).forEach(cmd -> CHANNEL_TO_CMD_MAP.put(cmd.getChannel(), cmd));
41 private final String command;
42 private final String channel;
44 AutomowerCommand(String command, String channel) {
45 this.command = command;
46 this.channel = channel;
49 public static Optional<AutomowerCommand> fromChannelUID(ChannelUID channelUID) {
50 return Optional.ofNullable(CHANNEL_TO_CMD_MAP.get(channelUID.getId()));
53 public String getCommand() {
57 public String getChannel() {