mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add DeviceInfo
to pyLoad integration (#120232)
* Add device info to pyLoad integration * Update homeassistant/components/pyload/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/pyload/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove name, add entry_type --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
84d1d11138
commit
826587abb2
@ -36,6 +36,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
||||||
@ -150,6 +151,8 @@ async def async_setup_entry(
|
|||||||
class PyLoadSensor(SensorEntity):
|
class PyLoadSensor(SensorEntity):
|
||||||
"""Representation of a pyLoad sensor."""
|
"""Representation of a pyLoad sensor."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
api: PyLoadAPI,
|
api: PyLoadAPI,
|
||||||
@ -158,13 +161,19 @@ class PyLoadSensor(SensorEntity):
|
|||||||
entry_id: str,
|
entry_id: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a new pyLoad sensor."""
|
"""Initialize a new pyLoad sensor."""
|
||||||
self._attr_name = f"{client_name} {entity_description.name}"
|
|
||||||
self.type = entity_description.key
|
self.type = entity_description.key
|
||||||
self.api = api
|
self.api = api
|
||||||
self._attr_unique_id = f"{entry_id}_{entity_description.key}"
|
self._attr_unique_id = f"{entry_id}_{entity_description.key}"
|
||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
self._attr_available = False
|
self._attr_available = False
|
||||||
self.data: StatusServerResponse
|
self.data: StatusServerResponse
|
||||||
|
self.device_info = DeviceInfo(
|
||||||
|
entry_type=DeviceEntryType.SERVICE,
|
||||||
|
manufacturer="PyLoad Team",
|
||||||
|
model="pyLoad",
|
||||||
|
configuration_url=api.api_url,
|
||||||
|
identifiers={(DOMAIN, entry_id)},
|
||||||
|
)
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update state of sensor."""
|
"""Update state of sensor."""
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.pyload_speed',
|
'entity_id': 'sensor.pyload_speed',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -29,7 +29,7 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'pyLoad Speed',
|
'original_name': 'Speed',
|
||||||
'platform': 'pyload',
|
'platform': 'pyload',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
@ -66,7 +66,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.pyload_speed',
|
'entity_id': 'sensor.pyload_speed',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -83,7 +83,7 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'pyLoad Speed',
|
'original_name': 'Speed',
|
||||||
'platform': 'pyload',
|
'platform': 'pyload',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
@ -120,7 +120,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.pyload_speed',
|
'entity_id': 'sensor.pyload_speed',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -137,7 +137,7 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'pyLoad Speed',
|
'original_name': 'Speed',
|
||||||
'platform': 'pyload',
|
'platform': 'pyload',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
@ -351,7 +351,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.pyload_speed',
|
'entity_id': 'sensor.pyload_speed',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -368,7 +368,7 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'pyLoad Speed',
|
'original_name': 'Speed',
|
||||||
'platform': 'pyload',
|
'platform': 'pyload',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user