Search in sources :

Example 1 with SystemTriggerHandler

use of org.openhab.core.automation.internal.module.handler.SystemTriggerHandler in project openhab-core by openhab.

the class CoreModuleHandlerFactory method internalCreate.

@Override
@Nullable
protected synchronized ModuleHandler internalCreate(final Module module, final String ruleUID) {
    logger.trace("create {} -> {} : {}", module.getId(), module.getTypeUID(), ruleUID);
    final String moduleTypeUID = module.getTypeUID();
    if (module instanceof Trigger) {
        // Handle triggers
        if (GenericEventTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new GenericEventTriggerHandler((Trigger) module, bundleContext);
        } else if (ChannelEventTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new ChannelEventTriggerHandler((Trigger) module, bundleContext);
        } else if (ItemCommandTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new ItemCommandTriggerHandler((Trigger) module, bundleContext);
        } else if (SystemTriggerHandler.STARTLEVEL_MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new SystemTriggerHandler((Trigger) module, bundleContext);
        } else if (ThingStatusTriggerHandler.CHANGE_MODULE_TYPE_ID.equals(moduleTypeUID) || ThingStatusTriggerHandler.UPDATE_MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new ThingStatusTriggerHandler((Trigger) module, bundleContext);
        } else if (ItemStateTriggerHandler.CHANGE_MODULE_TYPE_ID.equals(moduleTypeUID) || ItemStateTriggerHandler.UPDATE_MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new ItemStateTriggerHandler((Trigger) module, bundleContext);
        } else if (GroupCommandTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new GroupCommandTriggerHandler((Trigger) module, bundleContext, itemRegistry);
        } else if (GroupStateTriggerHandler.CHANGE_MODULE_TYPE_ID.equals(moduleTypeUID) || GroupStateTriggerHandler.UPDATE_MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new GroupStateTriggerHandler((Trigger) module, bundleContext, itemRegistry);
        }
    } else if (module instanceof Condition) {
        // Handle conditions
        if (ItemStateConditionHandler.ITEM_STATE_CONDITION.equals(moduleTypeUID)) {
            return new ItemStateConditionHandler((Condition) module, itemRegistry);
        } else if (GenericEventConditionHandler.MODULETYPE_ID.equals(moduleTypeUID)) {
            return new GenericEventConditionHandler((Condition) module);
        } else if (CompareConditionHandler.MODULE_TYPE.equals(moduleTypeUID)) {
            return new CompareConditionHandler((Condition) module);
        }
    } else if (module instanceof Action) {
        // Handle actions
        if (ItemCommandActionHandler.ITEM_COMMAND_ACTION.equals(moduleTypeUID)) {
            return new ItemCommandActionHandler((Action) module, eventPublisher, itemRegistry);
        } else if (ItemStateUpdateActionHandler.ITEM_STATE_UPDATE_ACTION.equals(moduleTypeUID)) {
            return new ItemStateUpdateActionHandler((Action) module, eventPublisher, itemRegistry);
        } else if (RuleEnablementActionHandler.UID.equals(moduleTypeUID)) {
            return new RuleEnablementActionHandler((Action) module);
        } else if (RunRuleActionHandler.UID.equals(moduleTypeUID)) {
            return new RunRuleActionHandler((Action) module);
        }
    }
    logger.error("The ModuleHandler is not supported: {}", moduleTypeUID);
    return null;
}
Also used : Condition(org.openhab.core.automation.Condition) GenericEventConditionHandler(org.openhab.core.automation.internal.module.handler.GenericEventConditionHandler) Action(org.openhab.core.automation.Action) ItemStateUpdateActionHandler(org.openhab.core.automation.internal.module.handler.ItemStateUpdateActionHandler) ThingStatusTriggerHandler(org.openhab.core.automation.internal.module.handler.ThingStatusTriggerHandler) ItemStateTriggerHandler(org.openhab.core.automation.internal.module.handler.ItemStateTriggerHandler) ItemCommandTriggerHandler(org.openhab.core.automation.internal.module.handler.ItemCommandTriggerHandler) GroupCommandTriggerHandler(org.openhab.core.automation.internal.module.handler.GroupCommandTriggerHandler) GroupStateTriggerHandler(org.openhab.core.automation.internal.module.handler.GroupStateTriggerHandler) ItemCommandActionHandler(org.openhab.core.automation.internal.module.handler.ItemCommandActionHandler) SystemTriggerHandler(org.openhab.core.automation.internal.module.handler.SystemTriggerHandler) ChannelEventTriggerHandler(org.openhab.core.automation.internal.module.handler.ChannelEventTriggerHandler) RuleEnablementActionHandler(org.openhab.core.automation.internal.module.handler.RuleEnablementActionHandler) Trigger(org.openhab.core.automation.Trigger) GenericEventTriggerHandler(org.openhab.core.automation.internal.module.handler.GenericEventTriggerHandler) ItemStateConditionHandler(org.openhab.core.automation.internal.module.handler.ItemStateConditionHandler) CompareConditionHandler(org.openhab.core.automation.internal.module.handler.CompareConditionHandler) RunRuleActionHandler(org.openhab.core.automation.internal.module.handler.RunRuleActionHandler) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

Nullable (org.eclipse.jdt.annotation.Nullable)1 Action (org.openhab.core.automation.Action)1 Condition (org.openhab.core.automation.Condition)1 Trigger (org.openhab.core.automation.Trigger)1 ChannelEventTriggerHandler (org.openhab.core.automation.internal.module.handler.ChannelEventTriggerHandler)1 CompareConditionHandler (org.openhab.core.automation.internal.module.handler.CompareConditionHandler)1 GenericEventConditionHandler (org.openhab.core.automation.internal.module.handler.GenericEventConditionHandler)1 GenericEventTriggerHandler (org.openhab.core.automation.internal.module.handler.GenericEventTriggerHandler)1 GroupCommandTriggerHandler (org.openhab.core.automation.internal.module.handler.GroupCommandTriggerHandler)1 GroupStateTriggerHandler (org.openhab.core.automation.internal.module.handler.GroupStateTriggerHandler)1 ItemCommandActionHandler (org.openhab.core.automation.internal.module.handler.ItemCommandActionHandler)1 ItemCommandTriggerHandler (org.openhab.core.automation.internal.module.handler.ItemCommandTriggerHandler)1 ItemStateConditionHandler (org.openhab.core.automation.internal.module.handler.ItemStateConditionHandler)1 ItemStateTriggerHandler (org.openhab.core.automation.internal.module.handler.ItemStateTriggerHandler)1 ItemStateUpdateActionHandler (org.openhab.core.automation.internal.module.handler.ItemStateUpdateActionHandler)1 RuleEnablementActionHandler (org.openhab.core.automation.internal.module.handler.RuleEnablementActionHandler)1 RunRuleActionHandler (org.openhab.core.automation.internal.module.handler.RunRuleActionHandler)1 SystemTriggerHandler (org.openhab.core.automation.internal.module.handler.SystemTriggerHandler)1 ThingStatusTriggerHandler (org.openhab.core.automation.internal.module.handler.ThingStatusTriggerHandler)1