ForecastSolar - power production now w not k w (#53797)

This commit is contained in:
B-Hartley 2021-08-01 23:01:34 +01:00 committed by GitHub
parent da1a9bcbf0
commit 736fb2e90d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 11 deletions

View File

@ -53,7 +53,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
key="power_production_now", key="power_production_now",
name="Estimated Power Production - Now", name="Estimated Power Production - Now",
device_class=DEVICE_CLASS_POWER, 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, state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=POWER_WATT, unit_of_measurement=POWER_WATT,
), ),
@ -61,8 +61,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
key="power_production_next_hour", key="power_production_next_hour",
state=lambda estimate: estimate.power_production_at_time( state=lambda estimate: estimate.power_production_at_time(
estimate.now() + timedelta(hours=1) estimate.now() + timedelta(hours=1)
) ),
/ 1000,
name="Estimated Power Production - Next Hour", name="Estimated Power Production - Next Hour",
device_class=DEVICE_CLASS_POWER, device_class=DEVICE_CLASS_POWER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -72,8 +71,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
key="power_production_next_12hours", key="power_production_next_12hours",
state=lambda estimate: estimate.power_production_at_time( state=lambda estimate: estimate.power_production_at_time(
estimate.now() + timedelta(hours=12) estimate.now() + timedelta(hours=12)
) ),
/ 1000,
name="Estimated Power Production - Next 12 Hours", name="Estimated Power Production - Next 12 Hours",
device_class=DEVICE_CLASS_POWER, device_class=DEVICE_CLASS_POWER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -83,8 +81,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
key="power_production_next_24hours", key="power_production_next_24hours",
state=lambda estimate: estimate.power_production_at_time( state=lambda estimate: estimate.power_production_at_time(
estimate.now() + timedelta(hours=24) estimate.now() + timedelta(hours=24)
) ),
/ 1000,
name="Estimated Power Production - Next 24 Hours", name="Estimated Power Production - Next 24 Hours",
device_class=DEVICE_CLASS_POWER, device_class=DEVICE_CLASS_POWER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,

View File

@ -96,7 +96,7 @@ async def test_sensors(
assert entry assert entry
assert state assert state
assert entry.unique_id == f"{entry_id}_power_production_now" assert entry.unique_id == f"{entry_id}_power_production_now"
assert state.state == "300.0" assert state.state == "300000"
assert ( assert (
state.attributes.get(ATTR_FRIENDLY_NAME) == "Estimated Power Production - Now" state.attributes.get(ATTR_FRIENDLY_NAME) == "Estimated Power Production - Now"
) )
@ -175,17 +175,17 @@ async def test_disabled_by_default(
( (
"power_production_next_12hours", "power_production_next_12hours",
"Estimated Power Production - Next 12 Hours", "Estimated Power Production - Next 12 Hours",
"600.0", "600000",
), ),
( (
"power_production_next_24hours", "power_production_next_24hours",
"Estimated Power Production - Next 24 Hours", "Estimated Power Production - Next 24 Hours",
"700.0", "700000",
), ),
( (
"power_production_next_hour", "power_production_next_hour",
"Estimated Power Production - Next Hour", "Estimated Power Production - Next Hour",
"400.0", "400000",
), ),
], ],
) )