mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Add device_info
property to OpenWeatherMap entities (#49293)
This commit is contained in:
parent
7264c95217
commit
e9cf8db302
@ -3,7 +3,15 @@ from homeassistant.components.sensor import SensorEntity
|
|||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from .const import ATTRIBUTION, SENSOR_DEVICE_CLASS, SENSOR_NAME, SENSOR_UNIT
|
from .const import (
|
||||||
|
ATTRIBUTION,
|
||||||
|
DEFAULT_NAME,
|
||||||
|
DOMAIN,
|
||||||
|
MANUFACTURER,
|
||||||
|
SENSOR_DEVICE_CLASS,
|
||||||
|
SENSOR_NAME,
|
||||||
|
SENSOR_UNIT,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AbstractOpenWeatherMapSensor(SensorEntity):
|
class AbstractOpenWeatherMapSensor(SensorEntity):
|
||||||
@ -36,6 +44,17 @@ class AbstractOpenWeatherMapSensor(SensorEntity):
|
|||||||
"""Return a unique_id for this entity."""
|
"""Return a unique_id for this entity."""
|
||||||
return self._unique_id
|
return self._unique_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_info(self):
|
||||||
|
"""Return the device info."""
|
||||||
|
split_unique_id = self._unique_id.split("-")
|
||||||
|
return {
|
||||||
|
"identifiers": {(DOMAIN, f"{split_unique_id[0]}-{split_unique_id[1]}")},
|
||||||
|
"name": DEFAULT_NAME,
|
||||||
|
"manufacturer": MANUFACTURER,
|
||||||
|
"entry_type": "service",
|
||||||
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""Return the polling requirement of the entity."""
|
"""Return the polling requirement of the entity."""
|
||||||
|
@ -42,6 +42,7 @@ DOMAIN = "openweathermap"
|
|||||||
DEFAULT_NAME = "OpenWeatherMap"
|
DEFAULT_NAME = "OpenWeatherMap"
|
||||||
DEFAULT_LANGUAGE = "en"
|
DEFAULT_LANGUAGE = "en"
|
||||||
ATTRIBUTION = "Data provided by OpenWeatherMap"
|
ATTRIBUTION = "Data provided by OpenWeatherMap"
|
||||||
|
MANUFACTURER = "OpenWeather"
|
||||||
CONF_LANGUAGE = "language"
|
CONF_LANGUAGE = "language"
|
||||||
CONFIG_FLOW_VERSION = 2
|
CONFIG_FLOW_VERSION = 2
|
||||||
ENTRY_NAME = "name"
|
ENTRY_NAME = "name"
|
||||||
|
@ -12,9 +12,11 @@ from .const import (
|
|||||||
ATTR_API_WIND_BEARING,
|
ATTR_API_WIND_BEARING,
|
||||||
ATTR_API_WIND_SPEED,
|
ATTR_API_WIND_SPEED,
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
|
DEFAULT_NAME,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
ENTRY_NAME,
|
ENTRY_NAME,
|
||||||
ENTRY_WEATHER_COORDINATOR,
|
ENTRY_WEATHER_COORDINATOR,
|
||||||
|
MANUFACTURER,
|
||||||
)
|
)
|
||||||
from .weather_update_coordinator import WeatherUpdateCoordinator
|
from .weather_update_coordinator import WeatherUpdateCoordinator
|
||||||
|
|
||||||
@ -55,6 +57,16 @@ class OpenWeatherMapWeather(WeatherEntity):
|
|||||||
"""Return a unique_id for this entity."""
|
"""Return a unique_id for this entity."""
|
||||||
return self._unique_id
|
return self._unique_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_info(self):
|
||||||
|
"""Return the device info."""
|
||||||
|
return {
|
||||||
|
"identifiers": {(DOMAIN, self._unique_id)},
|
||||||
|
"name": DEFAULT_NAME,
|
||||||
|
"manufacturer": MANUFACTURER,
|
||||||
|
"entry_type": "service",
|
||||||
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""Return the polling requirement of the entity."""
|
"""Return the polling requirement of the entity."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user