From 736fb2e90dab9ff702503000150d2283f8d28757 Mon Sep 17 00:00:00 2001 From: B-Hartley Date: Sun, 1 Aug 2021 23:01:34 +0100 Subject: [PATCH] ForecastSolar - power production now w not k w (#53797) --- homeassistant/components/forecast_solar/const.py | 11 ++++------- tests/components/forecast_solar/test_sensor.py | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/forecast_solar/const.py b/homeassistant/components/forecast_solar/const.py index 7f426d2847c..7ae6fe01d42 100644 --- a/homeassistant/components/forecast_solar/const.py +++ b/homeassistant/components/forecast_solar/const.py @@ -53,7 +53,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( key="power_production_now", name="Estimated Power Production - Now", device_class=DEVICE_CLASS_POWER, - state=lambda estimate: estimate.power_production_now / 1000, + state=lambda estimate: estimate.power_production_now, state_class=STATE_CLASS_MEASUREMENT, unit_of_measurement=POWER_WATT, ), @@ -61,8 +61,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( key="power_production_next_hour", state=lambda estimate: estimate.power_production_at_time( estimate.now() + timedelta(hours=1) - ) - / 1000, + ), name="Estimated Power Production - Next Hour", device_class=DEVICE_CLASS_POWER, entity_registry_enabled_default=False, @@ -72,8 +71,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( key="power_production_next_12hours", state=lambda estimate: estimate.power_production_at_time( estimate.now() + timedelta(hours=12) - ) - / 1000, + ), name="Estimated Power Production - Next 12 Hours", device_class=DEVICE_CLASS_POWER, entity_registry_enabled_default=False, @@ -83,8 +81,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( key="power_production_next_24hours", state=lambda estimate: estimate.power_production_at_time( estimate.now() + timedelta(hours=24) - ) - / 1000, + ), name="Estimated Power Production - Next 24 Hours", device_class=DEVICE_CLASS_POWER, entity_registry_enabled_default=False, diff --git a/tests/components/forecast_solar/test_sensor.py b/tests/components/forecast_solar/test_sensor.py index 8b8c1cc933e..a2b105ccbd1 100644 --- a/tests/components/forecast_solar/test_sensor.py +++ b/tests/components/forecast_solar/test_sensor.py @@ -96,7 +96,7 @@ async def test_sensors( assert entry assert state assert entry.unique_id == f"{entry_id}_power_production_now" - assert state.state == "300.0" + assert state.state == "300000" assert ( state.attributes.get(ATTR_FRIENDLY_NAME) == "Estimated Power Production - Now" ) @@ -175,17 +175,17 @@ async def test_disabled_by_default( ( "power_production_next_12hours", "Estimated Power Production - Next 12 Hours", - "600.0", + "600000", ), ( "power_production_next_24hours", "Estimated Power Production - Next 24 Hours", - "700.0", + "700000", ), ( "power_production_next_hour", "Estimated Power Production - Next Hour", - "400.0", + "400000", ), ], )