Skip to content

Commit

Permalink
lib.item log rules: log warning if invalid parameter is set
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Oct 21, 2024
1 parent 3e0ca0f commit 98d0014
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/item/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,13 @@ def __init__(self, smarthome, parent, path, config, items_instance=None):
elif attr in [KEY_LOG_RULES]:
if isinstance(value, list):
try:
value_dict = {k: v for od in value for k, v in od.items() if k in log_rules_keys}
value_dict = {}
for od in value:
for k, v in od.items():
if k in log_rules_keys:
value_dict[k] = v
else:
logger.warning(f"Item {self._path}: Ignoring '{k}' as it is not a valid log rule")
setattr(self, '_log_rules', value_dict)
except Exception as e:
logger.warning(f"Item {self._path}: Invalid list data for attribute '{KEY_LOG_RULES}': {value} - Exception: {e}")
Expand Down

0 comments on commit 98d0014

Please sign in to comment.