mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Manual trigger entity fix name influence entity_id (#97398)
This commit is contained in:
parent
2b4387f7c2
commit
1f11ce63fc
@ -157,7 +157,6 @@ class ScrapeSensor(
|
|||||||
"""Initialize a web scrape sensor."""
|
"""Initialize a web scrape sensor."""
|
||||||
CoordinatorEntity.__init__(self, coordinator)
|
CoordinatorEntity.__init__(self, coordinator)
|
||||||
ManualTriggerEntity.__init__(self, hass, trigger_entity_config)
|
ManualTriggerEntity.__init__(self, hass, trigger_entity_config)
|
||||||
self._attr_name = trigger_entity_config[CONF_NAME].template
|
|
||||||
self._attr_native_unit_of_measurement = unit_of_measurement
|
self._attr_native_unit_of_measurement = unit_of_measurement
|
||||||
self._attr_state_class = state_class
|
self._attr_state_class = state_class
|
||||||
self._select = select
|
self._select = select
|
||||||
|
@ -344,16 +344,15 @@ class SQLSensor(ManualTriggerEntity, SensorEntity):
|
|||||||
self._attr_extra_state_attributes = {}
|
self._attr_extra_state_attributes = {}
|
||||||
self._use_database_executor = use_database_executor
|
self._use_database_executor = use_database_executor
|
||||||
self._lambda_stmt = _generate_lambda_stmt(query)
|
self._lambda_stmt = _generate_lambda_stmt(query)
|
||||||
self._attr_name = (
|
if not yaml:
|
||||||
None if not yaml else trigger_entity_config[CONF_NAME].template
|
self._attr_name = None
|
||||||
)
|
self._attr_has_entity_name = True
|
||||||
self._attr_has_entity_name = not yaml
|
|
||||||
if not yaml and trigger_entity_config.get(CONF_UNIQUE_ID):
|
if not yaml and trigger_entity_config.get(CONF_UNIQUE_ID):
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
entry_type=DeviceEntryType.SERVICE,
|
entry_type=DeviceEntryType.SERVICE,
|
||||||
identifiers={(DOMAIN, trigger_entity_config[CONF_UNIQUE_ID])},
|
identifiers={(DOMAIN, trigger_entity_config[CONF_UNIQUE_ID])},
|
||||||
manufacturer="SQL",
|
manufacturer="SQL",
|
||||||
name=trigger_entity_config[CONF_NAME].template,
|
name=self.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
|
@ -626,6 +626,11 @@ class ManualTriggerEntity(TriggerBaseEntity):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
TriggerBaseEntity.__init__(self, hass, config)
|
TriggerBaseEntity.__init__(self, hass, config)
|
||||||
|
# Need initial rendering on `name` as it influence the `entity_id`
|
||||||
|
self._rendered[CONF_NAME] = config[CONF_NAME].async_render(
|
||||||
|
{},
|
||||||
|
parse_result=CONF_NAME in self._parse_result,
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _process_manual_data(self, value: Any | None = None) -> None:
|
def _process_manual_data(self, value: Any | None = None) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user