2 * Copyright 2017-2018 Gregory Moyer and contributors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openhab.binding.lametrictime.api.model;
18 import java.util.SortedMap;
19 import java.util.TreeMap;
21 import org.openhab.binding.lametrictime.api.local.model.BooleanParameter;
22 import org.openhab.binding.lametrictime.api.local.model.IntegerParameter;
23 import org.openhab.binding.lametrictime.api.local.model.Parameter;
24 import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
26 public class CountdownApp extends CoreApplication
28 private static final String NAME = "com.lametric.countdown";
30 private static final String ACTION_CONFIGURE = "countdown.configure";
31 private static final String ACTION_PAUSE = "countdown.pause";
32 private static final String ACTION_RESET = "countdown.reset";
33 private static final String ACTION_START = "countdown.start";
35 private static final String PARAMETER_DURATION = "duration";
36 private static final String PARAMETER_START_NOW = "start_now";
43 public CoreAction configure(int duration, boolean startNow)
45 SortedMap<String, Parameter> parameters = new TreeMap<>();
46 parameters.put(PARAMETER_DURATION, new IntegerParameter().withValue(duration));
47 parameters.put(PARAMETER_START_NOW, new BooleanParameter().withValue(startNow));
49 return new CoreAction(this,
50 new UpdateAction().withId(ACTION_CONFIGURE)
51 .withParameters(parameters));
54 public CoreAction pause()
56 return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE));
59 public CoreAction reset()
61 return new CoreAction(this, new UpdateAction().withId(ACTION_RESET));
64 public CoreAction start()
66 return new CoreAction(this, new UpdateAction().withId(ACTION_START));