mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Perform some Flu Near You code cleanup (#58860)
This commit is contained in:
parent
595184aa55
commit
24c899cf50
@ -26,8 +26,6 @@ PLATFORMS = ["sensor"]
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Flu Near You as config entry."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
||||
websession = aiohttp_client.async_get_clientsession(hass)
|
||||
client = Client(session=websession)
|
||||
|
||||
@ -64,6 +62,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
data_init_tasks.append(coordinator.async_refresh())
|
||||
|
||||
await asyncio.gather(*data_init_tasks)
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = coordinators
|
||||
|
||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||
|
@ -10,12 +10,7 @@ from homeassistant.components.sensor import (
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
ATTR_STATE,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
)
|
||||
from homeassistant.const import ATTR_STATE, CONF_LATITUDE, CONF_LONGITUDE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
@ -34,8 +29,6 @@ ATTR_STATE_REPORTS_LAST_WEEK = "state_reports_last_week"
|
||||
ATTR_STATE_REPORTS_THIS_WEEK = "state_reports_this_week"
|
||||
ATTR_ZIP_CODE = "zip_code"
|
||||
|
||||
DEFAULT_ATTRIBUTION = "Data provided by Flu Near You"
|
||||
|
||||
SENSOR_TYPE_CDC_LEVEL = "level"
|
||||
SENSOR_TYPE_CDC_LEVEL2 = "level2"
|
||||
SENSOR_TYPE_USER_CHICK = "chick"
|
||||
@ -140,8 +133,6 @@ async def async_setup_entry(
|
||||
class FluNearYouSensor(CoordinatorEntity, SensorEntity):
|
||||
"""Define a base Flu Near You sensor."""
|
||||
|
||||
DEFAULT_EXTRA_STATE_ATTRIBUTES = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
@ -166,7 +157,6 @@ class CdcSensor(FluNearYouSensor):
|
||||
def extra_state_attributes(self) -> Mapping[str, Any] | None:
|
||||
"""Return entity specific state attributes."""
|
||||
return {
|
||||
**self.DEFAULT_EXTRA_STATE_ATTRIBUTES,
|
||||
ATTR_REPORTED_DATE: self.coordinator.data["week_date"],
|
||||
ATTR_STATE: self.coordinator.data["name"],
|
||||
}
|
||||
@ -186,7 +176,6 @@ class UserSensor(FluNearYouSensor):
|
||||
def extra_state_attributes(self) -> Mapping[str, Any] | None:
|
||||
"""Return entity specific state attributes."""
|
||||
attrs = {
|
||||
**self.DEFAULT_EXTRA_STATE_ATTRIBUTES,
|
||||
ATTR_CITY: self.coordinator.data["local"]["city"].split("(")[0],
|
||||
ATTR_REPORTED_LATITUDE: self.coordinator.data["local"]["latitude"],
|
||||
ATTR_REPORTED_LONGITUDE: self.coordinator.data["local"]["longitude"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user