From 04ba3bf63c9f87e148a0137b2ae1638e25d0ac7e Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 21 Feb 2026 13:27:56 +0100 Subject: [PATCH] final commit before switching home --- virtualsensors.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/virtualsensors.py b/virtualsensors.py index d6e5c53..51b8798 100644 --- a/virtualsensors.py +++ b/virtualsensors.py @@ -7,8 +7,7 @@ import time from logger_interface import LoggerInterface class VirtualSensorBase: - def __init__(self,ad_api,logger_interface, virtual_sensor_name = None, sensor_name = None,super_entity_id = None, yaml_block = None,templates_library = None, constants = None,self_initialize = False): - assert yaml_block + def __init__(self,ad_api,logger_interface, virtual_sensor_name = None, sensor_name = None,super_entity_id = None, yaml_block = None,templates_library = None, constants = None,self_initialize = False): self.ad_api = ad_api self.logger_interface = logger_interface @@ -26,14 +25,18 @@ class VirtualSensorBase: self.virtual_sensor_name = sensor_name.split('.')[1] self.sensor_domain = self.sensor_name.split(".")[0] + assert yaml_block ,f"{self.sensor_name} have a null Yaml block" self.yaml_block = yaml_block self.templates_library = templates_library try: self.attributes = self.yaml_block['attributes'] except (TypeError,KeyError): self.attributes = dict() - if constants: self.constants = dict(constants) # we don't want to modify the parent dict + if constants: + self.constants = dict(constants) # we don't want to modify the parent dict + self.constants['self'] = self.sensor_name # we need to set self by ourself else: self.constants = {'self' : self.sensor_name } + if super_entity_id != None: self.constants['super'] = super_entity_id @@ -669,4 +672,4 @@ class VirtualSensors(): class VirtualSensorsApp(hass.Hass): def initialize(self): self.logger_interface = LoggerInterface(self.get_ad_api(),default_log = "virtualsensors_log") - self.virtual_sensors = VirtualSensors(ad_api = self.get_ad_api(),logger_interface = self.logger_interface,yaml_block = self.args,args_to_ignore_in_validation = ['module','class','global_dependencies','priority']) \ No newline at end of file + self.virtual_sensors = VirtualSensors(ad_api = self.get_ad_api(),logger_interface = self.logger_interface,yaml_block = self.args,args_to_ignore_in_validation = ['module','class','global_dependencies','priority','name','config_path']) \ No newline at end of file