Parameters are values which can easily be changed without having to reload the rules. Values will be picked up during runtime as soon as they get edited in the corresponding file. If the file doesn't exist yet it will automatically be generated in the configured param folder. Parameters are perfect for boundaries (e.g. if value is below param switch something on). Currently there are is ~HABApp.parameters.Parameter
and ~HABApp.parameters.DictParameter
available.
Created file:
min_value: 10
Rule A:
subkey1:
subkey2:
- a
- b
- c
Changes in the file will be automatically picked up through ~HABApp.parameters.Parameter
.
Since parameters used to provide flexible configuration for automation classes they can get quite complex and error prone. Thus it is possible to provide a validator for a file which will check the files for constraints, missing keys etc. when the file is loaded.
HABApp.parameters.set_file_validator
Example
Parameteres are not bound to rule instance and thus work everywhere in the rule file. It is possible to dynamically create rules from the contents of the parameter file.
It's even possible to automatically reload rules if the parameter file has changed: Just add the "reloads on" entry to the file.
key1:
v: 10
key2:
v: 12
HABApp.parameters.Parameter
HABApp.parameters.DictParameter