Add account type to Forecast.Solar integration (#55175)

pull/55187/head
Klaas Schoute 2021-08-25 11:16:23 +02:00 committed by GitHub
parent db5e159b6d
commit 49041b1469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -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,
}

View File

@ -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

View File

@ -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