public static StateConditionType initialize() { final ConfigDescriptionParameter state = ConfigDescriptionParameterBuilder.create(CONFIG_STATE, Type.TEXT) .withRequired(true) .withReadOnly(true) .withMultiple(false) .withLabel("State") .withDescription("State of the unit") .build(); final List<ConfigDescriptionParameter> config = new ArrayList<ConfigDescriptionParameter>(); config.add(state); Input leftOperand = new Input( INPUT_CURRENT_STATE, String.class.getName(), "Current State", "Current state of the unit", null, true, null, null); List<Input> input = new ArrayList<Input>(); input.add(leftOperand); return new StateConditionType(config, input); }
public static List<ConfigDescriptionParameter> getLocalizedConfigurationDescription( I18nProvider i18nProvider, List<ConfigDescriptionParameter> config, Bundle bundle, String uid, String prefix, Locale locale) { List<ConfigDescriptionParameter> configDescriptions = new ArrayList<ConfigDescriptionParameter>(); if (config != null) { for (ConfigDescriptionParameter parameter : config) { String parameterName = parameter.getName(); String llabel = getModuleTypeConfigParameterLabel( i18nProvider, bundle, uid, parameterName, parameter.getLabel(), prefix, locale); String ldescription = getModuleTypeConfigParameterDescription( i18nProvider, bundle, uid, parameterName, parameter.getDescription(), prefix, locale); String lpattern = getParameterPattern( i18nProvider, bundle, uid, parameterName, parameter.getPattern(), prefix, locale); List<ParameterOption> loptions = getLocalizedOptions( i18nProvider, parameter.getOptions(), bundle, uid, parameterName, prefix, locale); String lunitLabel = getUnitLabel( i18nProvider, bundle, uid, parameterName, parameter.getUnitLabel(), prefix, locale); configDescriptions.add( ConfigDescriptionParameterBuilder.create(parameterName, parameter.getType()) .withMinimum(parameter.getMinimum()) .withMaximum(parameter.getMaximum()) .withStepSize(parameter.getStepSize()) .withPattern(lpattern) .withRequired(parameter.isRequired()) .withMultiple(parameter.isMultiple()) .withReadOnly(parameter.isReadOnly()) .withContext(parameter.getContext()) .withDefault(parameter.getDefault()) .withLabel(llabel) .withDescription(ldescription) .withFilterCriteria(parameter.getFilterCriteria()) .withGroupName(parameter.getGroupName()) .withAdvanced(parameter.isAdvanced()) .withOptions(loptions) .withLimitToOptions(parameter.getLimitToOptions()) .withMultipleLimit(parameter.getMultipleLimit()) .withUnit(parameter.getUnit()) .withUnitLabel(lunitLabel) .build()); } } return configDescriptions; }
@Override public ConfigDescription getConfigDescription(URI uri, Locale locale) { if (uri == null) { return null; } if ("thing".equals(uri.getScheme()) == false) { return null; } ThingUID thingUID = new ThingUID(uri.getSchemeSpecificPart()); ThingType thingType = thingTypeRegistry.getThingType(thingUID.getThingTypeUID()); if (thingType == null) { return null; } // Is this a zwave thing? if (!thingUID.getBindingId().equals(ZWaveBindingConstants.BINDING_ID)) { return null; } // And make sure this is a node because we want to get the id off the end... if (!thingUID.getId().startsWith("node")) { return null; } int nodeId = Integer.parseInt(thingUID.getId().substring(4)); Thing thing = getThing(thingUID); if (thing == null) { return null; } ThingUID bridgeUID = thing.getBridgeUID(); // Get the controller for this thing Thing bridge = getThing(bridgeUID); if (bridge == null) { return null; } // Get its handler and node ZWaveControllerHandler handler = (ZWaveControllerHandler) bridge.getHandler(); ZWaveNode node = handler.getNode(nodeId); List<ConfigDescriptionParameterGroup> groups = new ArrayList<ConfigDescriptionParameterGroup>(); List<ConfigDescriptionParameter> parameters = new ArrayList<ConfigDescriptionParameter>(); groups.add(new ConfigDescriptionParameterGroup("actions", "", false, "Actions", null)); groups.add(new ConfigDescriptionParameterGroup("thingcfg", "home", false, "Device Configuration", null)); parameters.add(ConfigDescriptionParameterBuilder .create(ZWaveBindingConstants.CONFIGURATION_POLLPERIOD, Type.INTEGER).withLabel("Polling Period") .withDescription("Set the minimum polling period for this device<BR/>" + "Note that the polling period may be longer than set since the binding treats " + "polls as the lowest priority data within the network.") .withDefault("1800").withGroupName("thingcfg").build()); // If we support the wakeup class, then add the configuration if (node.getCommandClass(ZWaveCommandClass.CommandClass.WAKE_UP) != null) { groups.add(new ConfigDescriptionParameterGroup("wakeup", "sleep", false, "Wakeup Configuration", null)); parameters.add(ConfigDescriptionParameterBuilder .create(ZWaveBindingConstants.CONFIGURATION_WAKEUPINTERVAL, Type.TEXT).withLabel("Wakeup Interval") .withDescription("Sets the number of seconds that the device will wakeup<BR/>" + "Setting a shorter time will allow openHAB to configure the device more regularly, but may use more battery power.<BR>" + "<B>Note:</B> This setting does not impact device notifications such as alarms.") .withDefault("").withGroupName("wakeup").build()); parameters.add( ConfigDescriptionParameterBuilder.create(ZWaveBindingConstants.CONFIGURATION_WAKEUPNODE, Type.TEXT) .withLabel("Wakeup Node").withAdvanced(true) .withDescription("Sets the wakeup node to which the device will send notifications.<BR/>" + "This should normally be set to the openHAB controller - " + "if it isn't, openHAB will not receive notifications when the device wakes up, " + "and will not be able to configure the device.") .withDefault("").withGroupName("wakeup").build()); } // If we support the node name class, then add the configuration if (node.getCommandClass(ZWaveCommandClass.CommandClass.NODE_NAMING) != null) { parameters.add( ConfigDescriptionParameterBuilder.create(ZWaveBindingConstants.CONFIGURATION_NODENAME, Type.TEXT) .withLabel("Node Name").withDescription("Sets a string for the device name") .withGroupName("thingcfg").withDefault("").build()); parameters.add(ConfigDescriptionParameterBuilder .create(ZWaveBindingConstants.CONFIGURATION_NODELOCATION, Type.TEXT) .withDescription("Sets a string for the device location").withLabel("Node Location").withDefault("") .withGroupName("thingcfg").build()); } // If we support the switch_all class, then add the configuration if (node.getCommandClass(ZWaveCommandClass.CommandClass.SWITCH_ALL) != null) { List<ParameterOption> options = new ArrayList<ParameterOption>(); options.add(new ParameterOption("0", "Exclude from All On and All Off groups")); options.add(new ParameterOption("1", "Include in All On group")); options.add(new ParameterOption("2", "Include in All Off group")); options.add(new ParameterOption("255", "Include in All On and All Off groups")); parameters.add(ConfigDescriptionParameterBuilder .create(ZWaveBindingConstants.CONFIGURATION_SWITCHALLMODE, Type.TEXT).withLabel("Switch All Mode") .withDescription("Set the mode for the switch when receiving SWITCH ALL commands.").withDefault("0") .withGroupName("thingcfg").withOptions(options).build()); } // If we support DOOR_LOCK - add options if (node.getCommandClass(ZWaveCommandClass.CommandClass.DOOR_LOCK) != null) { parameters.add(ConfigDescriptionParameterBuilder .create(ZWaveBindingConstants.CONFIGURATION_DOORLOCKTIMEOUT, Type.TEXT).withLabel("Lock Timeout") .withDescription("Set the timeout on the lock.").withDefault("30").withGroupName("thingcfg") .build()); } ZWaveUserCodeCommandClass userCodeClass = (ZWaveUserCodeCommandClass) node .getCommandClass(ZWaveCommandClass.CommandClass.USER_CODE); if (userCodeClass != null && userCodeClass.getNumberOfSupportedCodes() > 0) { groups.add(new ConfigDescriptionParameterGroup("usercode", "lock", false, "User Code", null)); for (int code = 1; code <= userCodeClass.getNumberOfSupportedCodes(); code++) { parameters.add(ConfigDescriptionParameterBuilder .create(ZWaveBindingConstants.CONFIGURATION_USERCODE + code, Type.TEXT) .withLabel("Code " + code).withDescription("Set the user code (4 to 10 numbers)") .withDefault("").withGroupName("usercode").build()); } } List<ParameterOption> options = new ArrayList<ParameterOption>(); options.add(new ParameterOption(ZWaveBindingConstants.ACTION_CHECK_VALUE.toString(), "Do"));
if (node.isInitializationComplete() == true) { parameters.add(ConfigDescriptionParameterBuilder.create("action_reinit", Type.INTEGER) .withLabel("Reinitialise the device").withAdvanced(true).withOptions(options).withDefault("-232323") .withGroupName("actions").build()); >>>>>>> Z-Wave Updates
if (node.isInitializationComplete() == true) { parameters.add(ConfigDescriptionParameterBuilder.create("action_reinit", Type.TEXT) .withLabel("Reinitialise the device").withAdvanced(true).withDefault("GO").withGroupName("actions") .build()); =======
} else { // Otherwise, allow us to put this on the failed list parameters.add(ConfigDescriptionParameterBuilder.create("action_failed", Type.TEXT) .withLabel("Set device as FAILed").withAdvanced(true).withDefault("GO").withGroupName("actions") .build()); }
if (node.getNodeState() == ZWaveNodeState.FAILED) { parameters.add(ConfigDescriptionParameterBuilder.create("action_remove", Type.TEXT) .withLabel("Remove device from controller").withAdvanced(true).withDefault("GO") .withGroupName("actions").build()); } else {