Hi All,
I’m trying to move my OH config to GitHub and want to isolate passwords and API keys into one file, as well as some JSON settings that I use to store time of day settings (volumes, brightness, etc) but I’m having trouble understanding how to parse subkeys from a parameter file, and would love an example of how to get a rule re-load a parameter when changed.
My novice attempt at loading a subkey looks like this, but errors out:
import HABApp
import logging
class MyRuleWithParameters(HABApp.Rule):
def __init__(self):
super().__init__()
# construct parameter once, default_value can be anything
self.min_value = HABApp.Parameter('secrets', 'min_value', default_value=10)
# deeper structuring is possible through specifying multiple keys
self.min_value_nested = HABApp.Parameter(
'secrets',
'Rule A', 'subkey1', 'subkey2',
default_value=['a', 'b', 'c'] # defaults can also be dicts or lists
)
log.warning(self.min_value_nested['Rule A']['subkey1'])
log = logging.getLogger('MyRules')
MyRuleWithParameters()
TypeError: 'Parameter' object is not subscriptable
I’m sure it is something simple I’m missing, but I can’t turn it up through searches, and it seems like I shouldn’t need to load a yml parser…