final commit before switching home

This commit is contained in:
2026-02-21 13:27:56 +01:00
parent 45376aebcb
commit 04ba3bf63c

View File

@@ -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'])
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'])