Add DeviceInfo to Scrape (#97399)

* Add DeviceInfo to Scrape

* simplify

* review comment
pull/98065/head
G Johansson 2023-08-08 19:39:41 +02:00 committed by GitHub
parent 314d91692f
commit 8f2e30040c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -24,6 +24,8 @@ from homeassistant.const import (
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.template import Template
from homeassistant.helpers.template_entity import (
@ -164,6 +166,15 @@ class ScrapeSensor(
self._index = index
self._value_template = value_template
self._attr_native_value = None
if not yaml and (unique_id := trigger_entity_config.get(CONF_UNIQUE_ID)):
self._attr_name = None
self._attr_has_entity_name = True
self._attr_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, unique_id)},
manufacturer="Scrape",
name=self.name,
)
def _extract_value(self) -> Any:
"""Parse the html extraction in the executor."""