The rules module contains some utility functions and a decorator that can:
decorate a Jython class to create a
whenfunction decorator to create a
rule(name=None, description=None, tags=None)¶
This decorator can be used with both functions and classes to create rules.
See Decorators for a full description of how to use this decorator.
@rule('name', 'description', ['tag1', 'tag2']) @rule('name', tags=['tag1', 'tag2']) @rule('name')
name (str) – display name of the rule
description (str) – (optional) description of the rule
tags (list) – (optional) list of tags as strings
This function adds a
This is a wrapper of
automationManager.addRule()that does not require any additional imports. The addRule function is similar to the automationManager.addRule function, except that it can be safely used in modules (versus scripts). Since the automationManager is different for every script scope, the core.rules.addRule function looks up the automation manager for each call.
rule (SimpleRule) – a rule to add to openHAB
the Rule object that was created
- Return type
This function changes the UID of a rule, with the option to include a specified text.
This function needs some attention in order to work with the Automation API changes included in S1319.
rule (Rule) – the rule to modify
prefix (str) – (optional) the text to include in the UID