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.automation.pwm.internal.template;
15 import java.util.Collections;
16 import java.util.HashMap;
17 import java.util.HashSet;
18 import java.util.List;
21 import java.util.UUID;
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;
35 * Rule template for the PWM automation module.
37 * @author Fabian Wolter - Initial Contribution
40 public class PWMRuleTemplate extends RuleTemplate {
41 public static final String UID = "PWMRuleTemplate";
43 public static PWMRuleTemplate initialize() {
44 final String triggerId = UUID.randomUUID().toString();
46 final List<Trigger> triggers = Collections.singletonList(ModuleBuilder.createTrigger().withId(triggerId)
47 .withTypeUID(PWMTriggerType.UID).withLabel("PWM Trigger").build());
49 final Map<String, String> actionInputs = new HashMap<String, String>();
50 actionInputs.put(PWMConstants.INPUT, triggerId + "." + PWMConstants.OUTPUT);
52 Set<String> tags = new HashSet<String>();
55 return new PWMRuleTemplate(tags, triggers, Collections.emptyList(), Collections.emptyList(),
56 Collections.emptyList());
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,