diff --git a/README.md b/README.md index 5c6dc2e..1ce14e1 100644 --- a/README.md +++ b/README.md @@ -68,14 +68,13 @@ for today and 2 days forward. # Example configuration.yaml entry gismeteo: sweet_home: - sensors: {} dacha: name: Our Country House latitude: ... longitude: ... - sensors: - forecast_days: 2 + add_sensors: yes + forecast_days: 2 ``` See below detailed descriptions to configure component. @@ -107,14 +106,15 @@ I put a lot of work into making this repo and component available and updated to > _(float) (Optional) (Default: coordinates from the Home Assistant configuration)_\ > Longitude coordinate to monitor weather of (required if `latitude` is specified). > -> **sensors:**\ -> _(list) (Optional)_\ -> Setup for list of forecast sensors to display in the frontend. +> **add_sensors:**\ +> _(boolean) (Optional) (Default: false)_\ +> Enable this option to add current weather and forecast sensors to the frontend. > -> > **forecast_days:**\ -> > _(positive int; 0–6) (Optional) (Default: do not create any sensors)_\ -> > How many days ahead to make forecast sensors.\ -> > **Note:** If you only need a forecast sensors for today, specify `0`. +> **forecast_days:**\ +> _(positive int; 0–6) (Optional) (Default: do not create any sensors)_\ +> How many days ahead to make forecast sensors.\ +> **Note:** Forecast sensors will be created only if `add_sensors` option is enabled.\ +> **Note:** If you only need a forecast sensors for today, specify `0`. When `sensors` option are enabled, it creates 20 sensors. Each shows one aspect of current weather. Only few basic sensors are enabled by default. But you can enable any sensor through device settings. diff --git a/config/configuration.yaml b/config/configuration.yaml index e993dc9..cf27465 100644 --- a/config/configuration.yaml +++ b/config/configuration.yaml @@ -10,7 +10,6 @@ logger: gismeteo: sweet_home: - sensors: {} dacha: name: Our Country House diff --git a/custom_components/gismeteo/__init__.py b/custom_components/gismeteo/__init__.py index e8825f2..2890f02 100644 --- a/custom_components/gismeteo/__init__.py +++ b/custom_components/gismeteo/__init__.py @@ -18,10 +18,8 @@ CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, - CONF_MONITORED_CONDITIONS, CONF_NAME, CONF_SENSORS, - Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -33,10 +31,9 @@ from .api import ApiError, GismeteoApiClient from .const import ( + CONF_ADD_SENSORS, CONF_CACHE_DIR, - CONF_FORECAST, CONF_FORECAST_DAYS, - CONF_PLATFORM_FORMAT, COORDINATOR, DOMAIN, DOMAIN_YAML, @@ -51,27 +48,22 @@ forecast_days_int = vol.All(vol.Coerce(int), vol.Range(min=0, max=6)) -SENSORS_SCHEMA = vol.Schema( - { - vol.Optional(CONF_FORECAST_DAYS): forecast_days_int, - vol.Optional(CONF_MONITORED_CONDITIONS): cv.deprecated, - vol.Optional(CONF_FORECAST): cv.deprecated, - } -) - LOCATION_SCHEMA = vol.Schema( { vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, - vol.Optional(CONF_SENSORS): SENSORS_SCHEMA, + vol.Optional(CONF_SENSORS): cv.deprecated, + vol.Optional(CONF_ADD_SENSORS, default=False): cv.boolean, + vol.Optional(CONF_FORECAST_DAYS): forecast_days_int, vol.Optional(CONF_CACHE_DIR): cv.string, } ) CONFIG_SCHEMA = vol.Schema( - {DOMAIN: cv.schema_with_slug_keys(LOCATION_SCHEMA)}, extra=vol.ALLOW_EXTRA + {DOMAIN: cv.schema_with_slug_keys(vol.Any(LOCATION_SCHEMA, None))}, + extra=vol.ALLOW_EXTRA, ) @@ -99,8 +91,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: return True -def _get_api_client(hass: HomeAssistant, config: ConfigType) -> GismeteoApiClient: +def _get_api_client( + hass: HomeAssistant, config: ConfigType | None +) -> GismeteoApiClient: """Prepare Gismeteo API client instance.""" + if config is None: + config = {} return GismeteoApiClient( async_get_clientsession(hass), latitude=config.get(CONF_LATITUDE, hass.config.latitude), @@ -128,26 +124,12 @@ async def _async_get_coordinator(hass: HomeAssistant, unique_id, config: dict): return coordinator -def _convert_yaml_config(config: ConfigType) -> ConfigType: - """Convert YAML config to EntryFlow config.""" - cfg = config.copy() - - if CONF_SENSORS in cfg: - cfg.update(cfg[CONF_SENSORS]) - cfg.pop(CONF_SENSORS) - cfg[CONF_PLATFORM_FORMAT.format(Platform.SENSOR)] = True - - return cfg - - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Gismeteo as config entry.""" if entry.source == SOURCE_IMPORT: # Setup from configuration.yaml - for uid, cfg in hass.data[DOMAIN_YAML].items(): - cfg = _convert_yaml_config(cfg) - - coordinator = await _async_get_coordinator(hass, uid, cfg) + for uid, config in hass.data[DOMAIN_YAML].items(): + coordinator = await _async_get_coordinator(hass, uid, config) hass.data[DOMAIN][uid] = { COORDINATOR: coordinator, } diff --git a/custom_components/gismeteo/config_flow.py b/custom_components/gismeteo/config_flow.py index 8b429d2..f82f6fc 100644 --- a/custom_components/gismeteo/config_flow.py +++ b/custom_components/gismeteo/config_flow.py @@ -15,15 +15,15 @@ from homeassistant import config_entries from homeassistant.config_entries import SOURCE_IMPORT -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, Platform +from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.core import callback import homeassistant.helpers.config_validation as cv from . import _get_api_client, forecast_days_int # pylint: disable=unused-import from .api import ApiError from .const import ( # pylint: disable=unused-import + CONF_ADD_SENSORS, CONF_FORECAST_DAYS, - CONF_PLATFORM_FORMAT, DOMAIN, ) @@ -132,9 +132,7 @@ async def async_step_user(self, user_input: dict | None = None): data_schema=self.add_suggested_values_to_schema( vol.Schema( { - vol.Required( - CONF_PLATFORM_FORMAT.format(Platform.SENSOR) - ): bool, + vol.Required(CONF_ADD_SENSORS, default=False): bool, vol.Optional(CONF_FORECAST_DAYS): forecast_days_int, } ), diff --git a/custom_components/gismeteo/const.py b/custom_components/gismeteo/const.py index 37d3d9b..b4c4e34 100644 --- a/custom_components/gismeteo/const.py +++ b/custom_components/gismeteo/const.py @@ -62,18 +62,13 @@ # Configuration and options CONF_CACHE_DIR: Final = "cache_dir" -CONF_FORECAST: Final = "forecast" +CONF_ADD_SENSORS: Final = "add_sensors" CONF_FORECAST_DAYS: Final = "forecast_days" -CONF_PLATFORMS: Final = "platforms" -CONF_YAML: Final = "_yaml" -CONF_PLATFORM_FORMAT: Final = "_platform_{}" # Defaults DEFAULT_NAME: Final = "Gismeteo" # Attributes -ATTR_LAST_UPDATED: Final = "last_updated" -# ATTR_SUNRISE: Final = "sunrise" ATTR_SUNSET: Final = "sunset" # diff --git a/custom_components/gismeteo/sensor.py b/custom_components/gismeteo/sensor.py index f6d79ab..6836932 100644 --- a/custom_components/gismeteo/sensor.py +++ b/custom_components/gismeteo/sensor.py @@ -19,16 +19,16 @@ ) from homeassistant.components.weather import ATTR_FORECAST_CONDITION from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import CONF_NAME, Platform +from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, StateType -from . import GismeteoDataUpdateCoordinator, _convert_yaml_config, deslugify +from . import GismeteoDataUpdateCoordinator, deslugify from .const import ( ATTRIBUTION, + CONF_ADD_SENSORS, CONF_FORECAST_DAYS, - CONF_PLATFORM_FORMAT, COORDINATOR, DOMAIN, DOMAIN_YAML, @@ -75,23 +75,23 @@ async def async_setup_entry( entities = [] if config_entry.source == SOURCE_IMPORT: # Setup from configuration.yaml - for uid, cfg in hass.data[DOMAIN_YAML].items(): - cfg = _convert_yaml_config(cfg) - - if cfg.get(CONF_PLATFORM_FORMAT.format(Platform.SENSOR), False) is False: + for uid, config in hass.data[DOMAIN_YAML].items(): + if config is None: + config = {} + if not config.get(CONF_ADD_SENSORS): continue # pragma: no cover - location_name = cfg.get(CONF_NAME, deslugify(uid)) + location_name = config.get(CONF_NAME, deslugify(uid)) coordinator = hass.data[DOMAIN][uid][COORDINATOR] - entities.extend(_gen_entities(location_name, coordinator, cfg)) + entities.extend(_gen_entities(location_name, coordinator, config)) else: # Setup from config entry config = config_entry.data.copy() # type: ConfigType config.update(config_entry.options) - if config.get(CONF_PLATFORM_FORMAT.format(Platform.SENSOR), False) is False: + if not config.get(CONF_ADD_SENSORS): return # pragma: no cover location_name = config[CONF_NAME] diff --git a/custom_components/gismeteo/translations/en.json b/custom_components/gismeteo/translations/en.json index e16e1c4..a1bafd3 100644 --- a/custom_components/gismeteo/translations/en.json +++ b/custom_components/gismeteo/translations/en.json @@ -221,7 +221,7 @@ "step": { "user": { "data": { - "_platform_sensor": "Sensor entities enabled", + "add_sensors": "Sensor entities enabled", "forecast_days": "Forecast sensors to show (days)" }, "title": "Gismeteo Options" diff --git a/custom_components/gismeteo/translations/ru.json b/custom_components/gismeteo/translations/ru.json index a4a69d2..3186c8a 100644 --- a/custom_components/gismeteo/translations/ru.json +++ b/custom_components/gismeteo/translations/ru.json @@ -221,7 +221,7 @@ "step": { "user": { "data": { - "_platform_sensor": "Сенсоры включены", + "add_sensors": "Сенсоры включены", "forecast_days": "Сенсоры прогноза на (дней)" }, "title": "Настройки Gismeteo" diff --git a/custom_components/gismeteo/weather.py b/custom_components/gismeteo/weather.py index 9e32d56..d0a274b 100644 --- a/custom_components/gismeteo/weather.py +++ b/custom_components/gismeteo/weather.py @@ -25,7 +25,7 @@ ) from homeassistant.core import HomeAssistant, callback -from . import GismeteoDataUpdateCoordinator, _convert_yaml_config, deslugify +from . import GismeteoDataUpdateCoordinator, deslugify from .const import ATTRIBUTION, COORDINATOR, DOMAIN, DOMAIN_YAML, ForecastMode from .entity import GismeteoEntity @@ -37,10 +37,10 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie entities = [] if config_entry.source == SOURCE_IMPORT: # Setup from configuration.yaml - for uid, cfg in hass.data[DOMAIN_YAML].items(): - cfg = _convert_yaml_config(cfg) - - location_name = cfg.get(CONF_NAME, deslugify(uid)) + for uid, config in hass.data[DOMAIN_YAML].items(): + if config is None: + config = {} + location_name = config.get(CONF_NAME, deslugify(uid)) coordinator = hass.data[DOMAIN][uid][COORDINATOR] entities.append(GismeteoWeather(coordinator, location_name)) diff --git a/tests/const.py b/tests/const.py index 83f2560..3317d7c 100644 --- a/tests/const.py +++ b/tests/const.py @@ -1,34 +1,28 @@ """Constants for tests.""" -from custom_components.gismeteo.const import CONF_PLATFORM_FORMAT -from homeassistant.const import ( - CONF_LATITUDE, - CONF_LONGITUDE, - CONF_NAME, - CONF_SENSORS, - Platform, -) +from custom_components.gismeteo.const import CONF_ADD_SENSORS +from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME -FAKE_NAME = "Home" -FAKE_UNIQUE_ID = "test_id" -FAKE_LATITUDE = 55.55 -FAKE_LONGITUDE = 122.12 +TEST_NAME = "Home" +TEST_UNIQUE_ID = "test_id" +TEST_LATITUDE = 55.55 +TEST_LONGITUDE = 122.12 -FAKE_CONFIG = { - CONF_NAME: FAKE_NAME, - CONF_LATITUDE: FAKE_LATITUDE, - CONF_LONGITUDE: FAKE_LONGITUDE, +TEST_CONFIG = { + CONF_NAME: TEST_NAME, + CONF_LATITUDE: TEST_LATITUDE, + CONF_LONGITUDE: TEST_LONGITUDE, } -FAKE_CONFIG_OPTIONS = { - CONF_PLATFORM_FORMAT.format(Platform.SENSOR): True, +TEST_CONFIG_OPTIONS = { + CONF_ADD_SENSORS: True, } -FAKE_CONFIG_YAML = { +TEST_CONFIG_YAML = { "home": { - CONF_NAME: FAKE_NAME, - CONF_LATITUDE: FAKE_LATITUDE, - CONF_LONGITUDE: FAKE_LONGITUDE, - CONF_SENSORS: {}, + CONF_NAME: TEST_NAME, + CONF_LATITUDE: TEST_LATITUDE, + CONF_LONGITUDE: TEST_LONGITUDE, + CONF_ADD_SENSORS: True, }, } diff --git a/tests/test__init.py b/tests/test__init.py index 92bceca..afa84fa 100644 --- a/tests/test__init.py +++ b/tests/test__init.py @@ -5,22 +5,21 @@ from pytest_homeassistant_custom_component.common import MockConfigEntry, load_fixture -from custom_components.gismeteo import _convert_yaml_config, deslugify +from custom_components.gismeteo import deslugify from custom_components.gismeteo.api import ApiError, GismeteoApiClient -from custom_components.gismeteo.const import CONF_PLATFORM_FORMAT, DOMAIN, DOMAIN_YAML +from custom_components.gismeteo.const import DOMAIN, DOMAIN_YAML from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry, ConfigEntryState -from homeassistant.const import CONF_SENSORS from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component from .const import ( - FAKE_CONFIG, - FAKE_CONFIG_OPTIONS, - FAKE_CONFIG_YAML, - FAKE_NAME, - FAKE_UNIQUE_ID, + TEST_CONFIG, + TEST_CONFIG_OPTIONS, + TEST_CONFIG_YAML, + TEST_NAME, + TEST_UNIQUE_ID, ) @@ -39,10 +38,10 @@ async def async_init_integration( if config_entry is None: config_entry = MockConfigEntry( domain=DOMAIN, - title=FAKE_NAME, - unique_id=FAKE_UNIQUE_ID, - data=FAKE_CONFIG, - options=FAKE_CONFIG_OPTIONS, + title=TEST_NAME, + unique_id=TEST_UNIQUE_ID, + data=TEST_CONFIG, + options=TEST_CONFIG_OPTIONS, ) config_entry.add_to_hass(hass) @@ -62,28 +61,13 @@ async def test_async_setup(hass: HomeAssistant): async def test_async_setup_yaml(hass: HomeAssistant): """Test a successful setup component from YAML.""" with patch.object(hass.config_entries.flow, "async_init") as init: - await async_setup_component(hass, DOMAIN, {DOMAIN: FAKE_CONFIG_YAML}) + await async_setup_component(hass, DOMAIN, {DOMAIN: TEST_CONFIG_YAML}) await hass.async_block_till_done() - assert hass.data[DOMAIN_YAML] == FAKE_CONFIG_YAML + assert hass.data[DOMAIN_YAML] == TEST_CONFIG_YAML assert init.call_count == 1 -def test__convert_yaml_config(): - """Test convert YAML config to EntryFlow config.""" - assert not _convert_yaml_config({}) - assert _convert_yaml_config({"qwe": "asd"}) == {"qwe": "asd"} - - cfg = { - CONF_SENSORS: {"zxc": "qwe"}, - } - expected = { - "zxc": "qwe", - CONF_PLATFORM_FORMAT.format(SENSOR_DOMAIN): True, - } - assert _convert_yaml_config(cfg) == expected - - async def test_async_setup_entry(hass: HomeAssistant, gismeteo_api): """Test a successful setup entry.""" await async_init_integration(hass) @@ -99,15 +83,15 @@ async def test_async_setup_entry(hass: HomeAssistant, gismeteo_api): async def test_async_setup_entry_yaml(hass: HomeAssistant, gismeteo_api): """Test a successful setup entry from YAML.""" - hass.data[DOMAIN_YAML] = FAKE_CONFIG_YAML + hass.data[DOMAIN_YAML] = TEST_CONFIG_YAML await async_init_integration( hass, MockConfigEntry( domain=DOMAIN, source=SOURCE_IMPORT, - title=FAKE_NAME, - unique_id=FAKE_UNIQUE_ID, + title=TEST_NAME, + unique_id=TEST_UNIQUE_ID, data={}, ), ) diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 87885c1..fbce0b4 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -6,12 +6,12 @@ import pytest from pytest_homeassistant_custom_component.common import MockConfigEntry -from custom_components.gismeteo.const import CONF_PLATFORM_FORMAT, DOMAIN +from custom_components.gismeteo.const import CONF_ADD_SENSORS, DOMAIN from homeassistant import config_entries, data_entry_flow -from homeassistant.const import CONF_NAME, Platform +from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant -from .const import FAKE_CONFIG +from .const import TEST_CONFIG # This fixture bypasses the actual setup of the integration @@ -50,14 +50,14 @@ async def test_successful_config_flow(hass: HomeAssistant, bypass_get_data): # If a user were to enter `test_username` for username and `test_password` # for password, it would result in this function call result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=FAKE_CONFIG + result["flow_id"], user_input=TEST_CONFIG ) # Check that the config flow is complete and a new entry is created with # the input data assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result["title"] == FAKE_CONFIG[CONF_NAME] - assert result["data"] == FAKE_CONFIG + assert result["title"] == TEST_CONFIG[CONF_NAME] + assert result["data"] == TEST_CONFIG assert result["result"] @@ -75,7 +75,7 @@ async def test_failed_config_flow(hass: HomeAssistant, error_on_get_data): assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input=FAKE_CONFIG + result["flow_id"], user_input=TEST_CONFIG ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -87,7 +87,7 @@ async def test_options_flow(hass: HomeAssistant): """Test an options flow.""" # Create a new MockConfigEntry and add to HASS (we're bypassing config # flow entirely) - entry = MockConfigEntry(domain=DOMAIN, data=FAKE_CONFIG, entry_id="test") + entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG, entry_id="test") entry.add_to_hass(hass) # Initialize an options flow @@ -100,16 +100,16 @@ async def test_options_flow(hass: HomeAssistant): # Enter some fake data into the form result = await hass.config_entries.options.async_configure( result["flow_id"], - user_input={CONF_PLATFORM_FORMAT.format(Platform.SENSOR): False}, + user_input={CONF_ADD_SENSORS: False}, ) # Verify that the flow finishes assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result["title"] == FAKE_CONFIG[CONF_NAME] + assert result["title"] == TEST_CONFIG[CONF_NAME] # Verify that the options were updated assert entry.options == { - CONF_PLATFORM_FORMAT.format(Platform.SENSOR): False, + CONF_ADD_SENSORS: False, } @@ -119,7 +119,7 @@ async def test_options_flow_fail(hass: HomeAssistant): # flow entirely) entry = MockConfigEntry( domain=DOMAIN, - data=FAKE_CONFIG, + data=TEST_CONFIG, entry_id="test", source=config_entries.SOURCE_IMPORT, ) diff --git a/tests/test_entity.py b/tests/test_entity.py index 9417931..d1ff8dd 100644 --- a/tests/test_entity.py +++ b/tests/test_entity.py @@ -8,7 +8,7 @@ from homeassistant.const import ATTR_ID from homeassistant.core import HomeAssistant -from tests.const import FAKE_UNIQUE_ID +from tests.const import TEST_UNIQUE_ID async def test_entity_initialization(hass: HomeAssistant): @@ -16,9 +16,9 @@ async def test_entity_initialization(hass: HomeAssistant): mock_api = Mock() mock_api.attributes = {ATTR_ID: "asd"} - coordinator = GismeteoDataUpdateCoordinator(hass, FAKE_UNIQUE_ID, mock_api) + coordinator = GismeteoDataUpdateCoordinator(hass, TEST_UNIQUE_ID, mock_api) - assert coordinator.unique_id == FAKE_UNIQUE_ID + assert coordinator.unique_id == TEST_UNIQUE_ID entity = GismeteoEntity(coordinator, "Test location") diff --git a/tests/test_sensor.py b/tests/test_sensor.py index a38ad88..b7de7b2 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -10,7 +10,7 @@ from homeassistant.const import UnitOfTemperature from homeassistant.core import HomeAssistant -from tests.const import FAKE_UNIQUE_ID +from tests.const import TEST_UNIQUE_ID @patch("custom_components.gismeteo.GismeteoDataUpdateCoordinator") @@ -32,7 +32,7 @@ async def test_entity_initialization(hass: HomeAssistant): mock_api.temperature = Mock(return_value=123) mock_api.attributes = {} - coordinator = GismeteoDataUpdateCoordinator(hass, FAKE_UNIQUE_ID, mock_api) + coordinator = GismeteoDataUpdateCoordinator(hass, TEST_UNIQUE_ID, mock_api) sensor = GismeteoSensor( coordinator, SensorEntityDescription( @@ -44,7 +44,7 @@ async def test_entity_initialization(hass: HomeAssistant): "Test", ) - assert sensor.unique_id == f"{FAKE_UNIQUE_ID}-temperature" + assert sensor.unique_id == f"{TEST_UNIQUE_ID}-temperature" assert sensor.should_poll is False assert sensor.available is True assert sensor.native_value == 123 diff --git a/tests/test_weather.py b/tests/test_weather.py index db8683e..861ebea 100644 --- a/tests/test_weather.py +++ b/tests/test_weather.py @@ -8,7 +8,7 @@ from homeassistant.const import UnitOfPressure, UnitOfSpeed, UnitOfTemperature from homeassistant.core import HomeAssistant -from tests.const import FAKE_UNIQUE_ID +from tests.const import TEST_UNIQUE_ID async def test_entity_initialization(hass: HomeAssistant): @@ -17,10 +17,10 @@ async def test_entity_initialization(hass: HomeAssistant): mock_api.condition = Mock(return_value="asd") mock_api.attributes = {} - coordinator = GismeteoDataUpdateCoordinator(hass, FAKE_UNIQUE_ID, mock_api) + coordinator = GismeteoDataUpdateCoordinator(hass, TEST_UNIQUE_ID, mock_api) entity = GismeteoWeather(coordinator, "Test") - assert entity.unique_id == FAKE_UNIQUE_ID + assert entity.unique_id == TEST_UNIQUE_ID assert entity.attribution == ATTRIBUTION assert entity.condition == "asd" assert entity.native_temperature_unit == UnitOfTemperature.CELSIUS