smarthomeNG / smarthome

Device integration platform for your smart home
https://www.smarthomeNG.de
GNU General Public License v3.0
122 stars 91 forks source link

item.py: allow log level to be set by eval expression #681

Closed onkelandy closed 1 month ago

msinn commented 1 month ago

@onkelandy , @Morg42 Seitdem ich nach diesen PR gepullt habe, fliegt mir SmartHomeNG nur noch um die Ohren.

Im Log habe ich zu dieversen Items folgende Exceptions:

2024-10-18  00:28:55 ERROR    lib.item.item          <built-in function id>: Invalid log_level template 'None' - (Exception: 'NoneType' object has no attribute 'replace')
2024-10-18  00:28:55 ERROR    lib.item.item          Item wohnung.kochen.heizung.hvac: problem creating: 'NoneType' object has no attribute 'upper'
Traceback (most recent call last):
  File "/usr/local/shng_dev/lib/item/item.py", line 551, in __init__
    child = Item(smarthome, self, child_path, value)
  File "/usr/local/shng_dev/lib/item/item.py", line 635, in __init__
    update = plugin.parse_item(self)
  File "/usr/local/shng_dev/plugins/rtr2/__init__.py", line 226, in parse_item
    self._rtr[rtr_id].update_rtr_items('Init')
  File "/usr/local/shng_dev/plugins/rtr2/__init__.py", line 590, in update_rtr_items
    self._update_item(self.hvac_item, self._mode.hvac, src=ignore_function)
  File "/usr/local/shng_dev/plugins/rtr2/__init__.py", line 616, in _update_item
    item(value, self.plugin.get_shortname(), src)
  File "/usr/local/shng_dev/lib/item/item.py", line 1539, in __call__
    self.__update(value, caller, source, dest, key, index)
  File "/usr/local/shng_dev/lib/item/item.py", line 2420, in __update
    self._set_value(value, caller, source, dest, prev_change=None, last_change=None)
  File "/usr/local/shng_dev/lib/item/item.py", line 2376, in _set_value
    self._log_on_change(value, caller, source, dest)
  File "/usr/local/shng_dev/lib/item/item.py", line 2312, in _log_on_change
    level = log_level.upper()
AttributeError: 'NoneType' object has no attribute 'upper'

Ich habe die Änderung bei mir lokal erstmal wieder raus gefahren, damit mein SmartHomeNG wieder läuft.

onkelandy commented 1 month ago

Oha, sorry. Da hat die Testabteilung wohl ein Szenario übersehen... Zeile 291 müsste self._log_level_attrib = "INFO" heißen. Ich pushe gleich und freue mich über erneuten Test.