feat: add app_name parameter to VirtualSensors and SmartObject for per app grouping in the dashboard
This commit is contained in:
@@ -105,13 +105,6 @@ class SmartObject(hass.Hass,LoggerInterface):
|
||||
else:
|
||||
attributes = dict()
|
||||
|
||||
# elif state is not None and entity.exists():
|
||||
# state_data = self.get_state(entity_id, attribute='all') or {}
|
||||
# current_attributes = state_data.get('attributes', {})
|
||||
# if current_attributes.get('ad_app') != self.name:
|
||||
# attributes = dict(current_attributes)
|
||||
# attributes['ad_app'] = self.name
|
||||
|
||||
attributes['ad_app'] = self.name
|
||||
|
||||
if friendly_name is not None: attributes['friendly_name'] = friendly_name
|
||||
@@ -123,19 +116,10 @@ class SmartObject(hass.Hass,LoggerInterface):
|
||||
if state is not None:
|
||||
entity.set_state(state=state, attributes=attributes)
|
||||
else:
|
||||
entity.set_state(state='unknown', attributes=attributes)
|
||||
if not entity.exists():
|
||||
entity.set_state(state='unknown')
|
||||
entity.set_state(attributes=attributes)
|
||||
|
||||
# if state is not None and attributes is not None:
|
||||
# self.set_state(entity_id, state=state, attributes=attributes)
|
||||
# elif state is not None:
|
||||
# if entity.exists():
|
||||
# self.set_state(entity_id, state=state)
|
||||
# else:
|
||||
# self.set_state(entity_id, state=state, attributes={'ad_app': self.name})
|
||||
# elif attributes is not None:
|
||||
# self.set_state(entity_id, attributes=attributes)
|
||||
# elif not entity.exists():
|
||||
# self.set_state(entity_id, state='unknown', attributes={'ad_app': self.name})
|
||||
return entity
|
||||
|
||||
# Override this in a subclass to return a default state string when the
|
||||
@@ -238,7 +222,7 @@ class SmartObject(hass.Hass,LoggerInterface):
|
||||
|
||||
# virtual_sensors: {...} → create derived sensors from YAML spec
|
||||
if 'virtual_sensors' in self.args:
|
||||
self.virtual_sensors = VirtualSensors(ad_api = self,logger_interface = self,super_entity_id = self.entity_id,yaml_block = self.args['virtual_sensors'],templates_library = self.templates_library,constants = self.constants)
|
||||
self.virtual_sensors = VirtualSensors(ad_api = self,logger_interface = self,super_entity_id = self.entity_id,yaml_block = self.args['virtual_sensors'],templates_library = self.templates_library,constants = self.constants,app_name = self.name)
|
||||
|
||||
# attributes_override: {attr: entity_id | static_value, ...}
|
||||
# Each attribute either mirrors a live HA sensor or holds a
|
||||
|
||||
Reference in New Issue
Block a user