Search in sources :

Example 1 with ItemStateTriggerHandler

use of org.eclipse.smarthome.automation.module.core.handler.ItemStateTriggerHandler in project smarthome by eclipse.

the class CoreModuleHandlerFactory method internalCreate.

@Override
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) {
        if (GenericEventTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new GenericEventTriggerHandler((Trigger) module, this.bundleContext);
        } else if (ChannelEventTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new ChannelEventTriggerHandler((Trigger) module, this.bundleContext);
        } else if (ItemCommandTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new ItemCommandTriggerHandler((Trigger) module, this.bundleContext);
        } else if (ItemStateTriggerHandler.CHANGE_MODULE_TYPE_ID.equals(moduleTypeUID) || ItemStateTriggerHandler.UPDATE_MODULE_TYPE_ID.equals(moduleTypeUID)) {
            return new ItemStateTriggerHandler((Trigger) module, this.bundleContext);
        }
    } else if (module instanceof Condition) {
        // Handle conditions
        if (ItemStateConditionHandler.ITEM_STATE_CONDITION.equals(moduleTypeUID)) {
            ItemStateConditionHandler handler = new ItemStateConditionHandler((Condition) module);
            handler.setItemRegistry(itemRegistry);
            return handler;
        } 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) {
        if (ItemCommandActionHandler.ITEM_COMMAND_ACTION.equals(moduleTypeUID)) {
            final ItemCommandActionHandler postCommandActionHandler = new ItemCommandActionHandler((Action) module);
            postCommandActionHandler.setEventPublisher(eventPublisher);
            postCommandActionHandler.setItemRegistry(itemRegistry);
            return postCommandActionHandler;
        } else if (RuleEnablementActionHandler.UID.equals(moduleTypeUID)) {
            return new RuleEnablementActionHandler((Action) module, ruleRegistry);
        } else if (RunRuleActionHandler.UID.equals(moduleTypeUID)) {
            return new RunRuleActionHandler((Action) module, ruleRegistry);
        }
    }
    logger.error("The ModuleHandler is not supported:{}", moduleTypeUID);
    return null;
}
Also used : Condition(org.eclipse.smarthome.automation.Condition) GenericEventConditionHandler(org.eclipse.smarthome.automation.module.core.handler.GenericEventConditionHandler) Action(org.eclipse.smarthome.automation.Action) ItemStateTriggerHandler(org.eclipse.smarthome.automation.module.core.handler.ItemStateTriggerHandler) ItemCommandTriggerHandler(org.eclipse.smarthome.automation.module.core.handler.ItemCommandTriggerHandler) ItemCommandActionHandler(org.eclipse.smarthome.automation.module.core.handler.ItemCommandActionHandler) ChannelEventTriggerHandler(org.eclipse.smarthome.automation.module.core.handler.ChannelEventTriggerHandler) RuleEnablementActionHandler(org.eclipse.smarthome.automation.module.core.handler.RuleEnablementActionHandler) Trigger(org.eclipse.smarthome.automation.Trigger) GenericEventTriggerHandler(org.eclipse.smarthome.automation.module.core.handler.GenericEventTriggerHandler) ItemStateConditionHandler(org.eclipse.smarthome.automation.module.core.handler.ItemStateConditionHandler) CompareConditionHandler(org.eclipse.smarthome.automation.module.core.handler.CompareConditionHandler) RunRuleActionHandler(org.eclipse.smarthome.automation.module.core.handler.RunRuleActionHandler)

Aggregations

Action (org.eclipse.smarthome.automation.Action)1 Condition (org.eclipse.smarthome.automation.Condition)1 Trigger (org.eclipse.smarthome.automation.Trigger)1 ChannelEventTriggerHandler (org.eclipse.smarthome.automation.module.core.handler.ChannelEventTriggerHandler)1 CompareConditionHandler (org.eclipse.smarthome.automation.module.core.handler.CompareConditionHandler)1 GenericEventConditionHandler (org.eclipse.smarthome.automation.module.core.handler.GenericEventConditionHandler)1 GenericEventTriggerHandler (org.eclipse.smarthome.automation.module.core.handler.GenericEventTriggerHandler)1 ItemCommandActionHandler (org.eclipse.smarthome.automation.module.core.handler.ItemCommandActionHandler)1 ItemCommandTriggerHandler (org.eclipse.smarthome.automation.module.core.handler.ItemCommandTriggerHandler)1 ItemStateConditionHandler (org.eclipse.smarthome.automation.module.core.handler.ItemStateConditionHandler)1 ItemStateTriggerHandler (org.eclipse.smarthome.automation.module.core.handler.ItemStateTriggerHandler)1 RuleEnablementActionHandler (org.eclipse.smarthome.automation.module.core.handler.RuleEnablementActionHandler)1 RunRuleActionHandler (org.eclipse.smarthome.automation.module.core.handler.RunRuleActionHandler)1