diff --git a/homeassistant/components/luftdaten/__init__.py b/homeassistant/components/luftdaten/__init__.py index 8725c25bf8e..9634ebdde48 100644 --- a/homeassistant/components/luftdaten/__init__.py +++ b/homeassistant/components/luftdaten/__init__.py @@ -1,4 +1,8 @@ -"""Support for Luftdaten stations.""" +"""Support for Sensor.Community stations. + +Sensor.Community was previously called Luftdaten, hence the domain differs from +the integration name. +""" from __future__ import annotations import logging @@ -23,7 +27,7 @@ CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False) async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: - """Set up Luftdaten as config entry.""" + """Set up Sensor.Community as config entry.""" # For backwards compat, set unique ID if entry.unique_id is None: @@ -31,26 +35,26 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry, unique_id=str(entry.data[CONF_SENSOR_ID]) ) - luftdaten = Luftdaten(entry.data[CONF_SENSOR_ID]) + sensor_community = Luftdaten(entry.data[CONF_SENSOR_ID]) async def async_update() -> dict[str, float | int]: """Update sensor/binary sensor data.""" try: - await luftdaten.get_data() + await sensor_community.get_data() except LuftdatenError as err: - raise UpdateFailed("Unable to retrieve data from luftdaten.info") from err + raise UpdateFailed("Unable to retrieve data from Sensor.Community") from err - if not luftdaten.values: - raise UpdateFailed("Did not receive sensor data from luftdaten.info") + if not sensor_community.values: + raise UpdateFailed("Did not receive sensor data from Sensor.Community") - data: dict[str, float | int] = luftdaten.values - data.update(luftdaten.meta) + data: dict[str, float | int] = sensor_community.values + data.update(sensor_community.meta) return data coordinator: DataUpdateCoordinator[dict[Any, Any]] = DataUpdateCoordinator( hass, _LOGGER, - name=f"{DOMAIN}_{luftdaten.sensor_id}", + name=f"{DOMAIN}_{sensor_community.sensor_id}", update_interval=DEFAULT_SCAN_INTERVAL, update_method=async_update, ) @@ -63,8 +67,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: - """Unload an Luftdaten config entry.""" - unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) - if unload_ok: + """Unload an Sensor.Community config entry.""" + if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS): del hass.data[DOMAIN][entry.entry_id] return unload_ok diff --git a/homeassistant/components/luftdaten/config_flow.py b/homeassistant/components/luftdaten/config_flow.py index d40eb3295c7..0fa800f1d8b 100644 --- a/homeassistant/components/luftdaten/config_flow.py +++ b/homeassistant/components/luftdaten/config_flow.py @@ -1,4 +1,4 @@ -"""Config flow to configure the Luftdaten component.""" +"""Config flow to configure the Sensor.Community integration.""" from __future__ import annotations from typing import Any @@ -16,8 +16,8 @@ import homeassistant.helpers.config_validation as cv from .const import CONF_SENSOR_ID, DOMAIN -class LuftDatenFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): - """Handle a Luftdaten config flow.""" +class SensorCommunityFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): + """Handle a Sensor.Community config flow.""" VERSION = 1 @@ -45,10 +45,10 @@ class LuftDatenFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(str(user_input[CONF_SENSOR_ID])) self._abort_if_unique_id_configured() - luftdaten = Luftdaten(user_input[CONF_SENSOR_ID]) + sensor_community = Luftdaten(user_input[CONF_SENSOR_ID]) try: - await luftdaten.get_data() - valid = await luftdaten.validate_sensor() + await sensor_community.get_data() + valid = await sensor_community.validate_sensor() except LuftdatenConnectionError: return self._show_form({CONF_SENSOR_ID: "cannot_connect"}) diff --git a/homeassistant/components/luftdaten/const.py b/homeassistant/components/luftdaten/const.py index ffeb3771e4e..b64079933cd 100644 --- a/homeassistant/components/luftdaten/const.py +++ b/homeassistant/components/luftdaten/const.py @@ -1,4 +1,4 @@ -"""Define constants for the Luftdaten component.""" +"""Define constants for the Sensor.Community integration.""" from datetime import timedelta ATTR_SENSOR_ID = "sensor_id" diff --git a/homeassistant/components/luftdaten/manifest.json b/homeassistant/components/luftdaten/manifest.json index 1a745e1060a..9cefc2dbc1d 100644 --- a/homeassistant/components/luftdaten/manifest.json +++ b/homeassistant/components/luftdaten/manifest.json @@ -1,6 +1,6 @@ { "domain": "luftdaten", - "name": "Luftdaten", + "name": "Sensor.Community", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/luftdaten", "requirements": ["luftdaten==0.7.1"], diff --git a/homeassistant/components/luftdaten/sensor.py b/homeassistant/components/luftdaten/sensor.py index 69ad30eb926..e8127b8d9be 100644 --- a/homeassistant/components/luftdaten/sensor.py +++ b/homeassistant/components/luftdaten/sensor.py @@ -1,4 +1,4 @@ -"""Support for Luftdaten sensors.""" +"""Support for Sensor.Community sensors.""" from __future__ import annotations from typing import cast @@ -79,11 +79,11 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: - """Set up a Luftdaten sensor based on a config entry.""" + """Set up a Sensor.Community sensor based on a config entry.""" coordinator = hass.data[DOMAIN][entry.entry_id] async_add_entities( - LuftdatenSensor( + SensorCommunitySensor( coordinator=coordinator, description=description, sensor_id=entry.data[CONF_SENSOR_ID], @@ -94,10 +94,10 @@ async def async_setup_entry( ) -class LuftdatenSensor(CoordinatorEntity, SensorEntity): - """Implementation of a Luftdaten sensor.""" +class SensorCommunitySensor(CoordinatorEntity, SensorEntity): + """Implementation of a Sensor.Community sensor.""" - _attr_attribution = "Data provided by luftdaten.info" + _attr_attribution = "Data provided by Sensor.Community" _attr_should_poll = False def __init__( @@ -108,7 +108,7 @@ class LuftdatenSensor(CoordinatorEntity, SensorEntity): sensor_id: int, show_on_map: bool, ) -> None: - """Initialize the Luftdaten sensor.""" + """Initialize the Sensor.Community sensor.""" super().__init__(coordinator=coordinator) self.entity_description = description self._attr_unique_id = f"{sensor_id}_{description.key}" @@ -119,7 +119,7 @@ class LuftdatenSensor(CoordinatorEntity, SensorEntity): configuration_url=f"https://devices.sensor.community/sensors/{sensor_id}/settings", identifiers={(DOMAIN, str(sensor_id))}, name=f"Sensor {sensor_id}", - manufacturer="Luftdaten.info", + manufacturer="Sensor.Community", ) if show_on_map: diff --git a/homeassistant/components/luftdaten/strings.json b/homeassistant/components/luftdaten/strings.json index d6b4602782e..508e12924d3 100644 --- a/homeassistant/components/luftdaten/strings.json +++ b/homeassistant/components/luftdaten/strings.json @@ -2,9 +2,8 @@ "config": { "step": { "user": { - "title": "Define Luftdaten", "data": { - "station_id": "Luftdaten Sensor ID", + "station_id": "Sensor ID", "show_on_map": "Show on map" } } diff --git a/homeassistant/components/luftdaten/translations/en.json b/homeassistant/components/luftdaten/translations/en.json index f784e360d5c..fa6a65dcaa7 100644 --- a/homeassistant/components/luftdaten/translations/en.json +++ b/homeassistant/components/luftdaten/translations/en.json @@ -9,9 +9,8 @@ "user": { "data": { "show_on_map": "Show on map", - "station_id": "Luftdaten Sensor ID" - }, - "title": "Define Luftdaten" + "station_id": "Sensor ID" + } } } } diff --git a/tests/components/luftdaten/test_sensor.py b/tests/components/luftdaten/test_sensor.py index 46570d6cb69..3cf4426d500 100644 --- a/tests/components/luftdaten/test_sensor.py +++ b/tests/components/luftdaten/test_sensor.py @@ -123,7 +123,7 @@ async def test_luftdaten_sensors( device_entry = device_registry.async_get(entry.device_id) assert device_entry assert device_entry.identifiers == {(DOMAIN, "12345")} - assert device_entry.manufacturer == "Luftdaten.info" + assert device_entry.manufacturer == "Sensor.Community" assert device_entry.name == "Sensor 12345" assert ( device_entry.configuration_url