]> git.basschouten.com Git - openhab-addons.git/blob
84268492164e33af99a85d0307e440740ae9bbf4
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.automation.pwm.internal.template;
14
15 import java.util.Collections;
16 import java.util.HashMap;
17 import java.util.HashSet;
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Set;
21 import java.util.UUID;
22
23 import org.eclipse.jdt.annotation.NonNullByDefault;
24 import org.openhab.automation.pwm.internal.PWMConstants;
25 import org.openhab.automation.pwm.internal.type.PWMTriggerType;
26 import org.openhab.core.automation.Action;
27 import org.openhab.core.automation.Condition;
28 import org.openhab.core.automation.Trigger;
29 import org.openhab.core.automation.Visibility;
30 import org.openhab.core.automation.template.RuleTemplate;
31 import org.openhab.core.automation.util.ModuleBuilder;
32 import org.openhab.core.config.core.ConfigDescriptionParameter;
33
34 /**
35  * Rule template for the PWM automation module.
36  *
37  * @author Fabian Wolter - Initial Contribution
38  */
39 @NonNullByDefault
40 public class PWMRuleTemplate extends RuleTemplate {
41     public static final String UID = "PWMRuleTemplate";
42
43     public static PWMRuleTemplate initialize() {
44         final String triggerId = UUID.randomUUID().toString();
45
46         final List<Trigger> triggers = List.of(ModuleBuilder.createTrigger().withId(triggerId)
47                 .withTypeUID(PWMTriggerType.UID).withLabel("PWM Trigger").build());
48
49         final Map<String, String> actionInputs = new HashMap<String, String>();
50         actionInputs.put(PWMConstants.INPUT, triggerId + "." + PWMConstants.OUTPUT);
51
52         Set<String> tags = new HashSet<String>();
53         tags.add("PWM");
54
55         return new PWMRuleTemplate(tags, triggers, Collections.emptyList(), Collections.emptyList(),
56                 Collections.emptyList());
57     }
58
59     public PWMRuleTemplate(Set<String> tags, List<Trigger> triggers, List<Condition> conditions, List<Action> actions,
60             List<ConfigDescriptionParameter> configDescriptions) {
61         super(UID, "PWM", "Template for a PWM rule", tags, triggers, conditions, actions, configDescriptions,
62                 Visibility.VISIBLE);
63     }
64 }