From 49041b1469500a9ff2ad165452a37fc9ca2607ff Mon Sep 17 00:00:00 2001 From: Klaas Schoute Date: Wed, 25 Aug 2021 11:16:23 +0200 Subject: [PATCH] Add account type to Forecast.Solar integration (#55175) --- homeassistant/components/forecast_solar/sensor.py | 8 +++++++- tests/components/forecast_solar/conftest.py | 1 + tests/components/forecast_solar/test_sensor.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/forecast_solar/sensor.py b/homeassistant/components/forecast_solar/sensor.py index 29ba14ac463..2ad86186652 100644 --- a/homeassistant/components/forecast_solar/sensor.py +++ b/homeassistant/components/forecast_solar/sensor.py @@ -5,7 +5,12 @@ from datetime import datetime from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_IDENTIFIERS, ATTR_MANUFACTURER, ATTR_NAME +from homeassistant.const import ( + ATTR_IDENTIFIERS, + ATTR_MANUFACTURER, + ATTR_MODEL, + ATTR_NAME, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType @@ -56,6 +61,7 @@ class ForecastSolarSensorEntity(CoordinatorEntity, SensorEntity): ATTR_IDENTIFIERS: {(DOMAIN, entry_id)}, ATTR_NAME: "Solar Production Forecast", ATTR_MANUFACTURER: "Forecast.Solar", + ATTR_MODEL: coordinator.data.account_type.value, ATTR_ENTRY_TYPE: ENTRY_TYPE_SERVICE, } diff --git a/tests/components/forecast_solar/conftest.py b/tests/components/forecast_solar/conftest.py index 8b9227a8d04..0bf080535f6 100644 --- a/tests/components/forecast_solar/conftest.py +++ b/tests/components/forecast_solar/conftest.py @@ -61,6 +61,7 @@ def mock_forecast_solar() -> Generator[None, MagicMock, None]: estimate = MagicMock(spec=models.Estimate) estimate.now.return_value = now estimate.timezone = "Europe/Amsterdam" + estimate.account_type.value = "public" estimate.energy_production_today = 100000 estimate.energy_production_tomorrow = 200000 estimate.power_production_now = 300000 diff --git a/tests/components/forecast_solar/test_sensor.py b/tests/components/forecast_solar/test_sensor.py index a2b105ccbd1..6c910d699c4 100644 --- a/tests/components/forecast_solar/test_sensor.py +++ b/tests/components/forecast_solar/test_sensor.py @@ -142,7 +142,7 @@ async def test_sensors( assert device_entry.manufacturer == "Forecast.Solar" assert device_entry.name == "Solar Production Forecast" assert device_entry.entry_type == ENTRY_TYPE_SERVICE - assert not device_entry.model + assert device_entry.model == "public" assert not device_entry.sw_version