Search in sources :

Example 1 with ScriptConditionHandler

use of org.eclipse.smarthome.automation.module.script.internal.handler.ScriptConditionHandler in project smarthome by eclipse.

the class ScriptModuleHandlerFactory method internalCreate.

@Override
protected ModuleHandler internalCreate(Module module, String ruleUID) {
    logger.trace("create {} -> {}", module.getId(), module.getTypeUID());
    String moduleTypeUID = module.getTypeUID();
    if (moduleTypeUID != null) {
        if (ScriptConditionHandler.SCRIPT_CONDITION.equals(moduleTypeUID) && module instanceof Condition) {
            ScriptConditionHandler handler = new ScriptConditionHandler((Condition) module, ruleUID, scriptEngineManager);
            return handler;
        } else if (ScriptActionHandler.SCRIPT_ACTION_ID.equals(moduleTypeUID) && module instanceof Action) {
            ScriptActionHandler handler = new ScriptActionHandler((Action) module, ruleUID, scriptEngineManager);
            return handler;
        } else {
            logger.error("The ModuleHandler is not supported: {}", moduleTypeUID);
        }
    } else {
        logger.error("ModuleType is not registered: {}", moduleTypeUID);
    }
    return null;
}
Also used : Condition(org.eclipse.smarthome.automation.Condition) ScriptConditionHandler(org.eclipse.smarthome.automation.module.script.internal.handler.ScriptConditionHandler) ScriptActionHandler(org.eclipse.smarthome.automation.module.script.internal.handler.ScriptActionHandler) Action(org.eclipse.smarthome.automation.Action)

Aggregations

Action (org.eclipse.smarthome.automation.Action)1 Condition (org.eclipse.smarthome.automation.Condition)1 ScriptActionHandler (org.eclipse.smarthome.automation.module.script.internal.handler.ScriptActionHandler)1 ScriptConditionHandler (org.eclipse.smarthome.automation.module.script.internal.handler.ScriptConditionHandler)1