mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Normalize to kWh when handling WS energy/fossil_energy_consumption (#79649)
* Normalize to kWh when handling WS energy/fossil_energy_consumption * Improve test
This commit is contained in:
parent
312770dbac
commit
5d7756885b
@ -13,6 +13,7 @@ from typing import Any, cast
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import recorder, websocket_api
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.integration_platform import (
|
||||
async_process_integration_platforms,
|
||||
@ -268,6 +269,7 @@ async def ws_get_fossil_energy_consumption(
|
||||
statistic_ids,
|
||||
"hour",
|
||||
True,
|
||||
{"energy": ENERGY_KILO_WATT_HOUR},
|
||||
)
|
||||
|
||||
def _combine_sum_statistics(
|
||||
|
@ -814,25 +814,25 @@ async def test_fossil_energy_consumption(hass, hass_ws_client, recorder_mock):
|
||||
"start": period1,
|
||||
"last_reset": None,
|
||||
"state": 0,
|
||||
"sum": 20,
|
||||
"sum": 20000,
|
||||
},
|
||||
{
|
||||
"start": period2,
|
||||
"last_reset": None,
|
||||
"state": 1,
|
||||
"sum": 30,
|
||||
"sum": 30000,
|
||||
},
|
||||
{
|
||||
"start": period3,
|
||||
"last_reset": None,
|
||||
"state": 2,
|
||||
"sum": 40,
|
||||
"sum": 40000,
|
||||
},
|
||||
{
|
||||
"start": period4,
|
||||
"last_reset": None,
|
||||
"state": 3,
|
||||
"sum": 50,
|
||||
"sum": 50000,
|
||||
},
|
||||
)
|
||||
external_energy_metadata_2 = {
|
||||
@ -841,7 +841,7 @@ async def test_fossil_energy_consumption(hass, hass_ws_client, recorder_mock):
|
||||
"name": "Total imported energy",
|
||||
"source": "test",
|
||||
"statistic_id": "test:total_energy_import_tariff_2",
|
||||
"unit_of_measurement": "kWh",
|
||||
"unit_of_measurement": "Wh",
|
||||
}
|
||||
external_co2_statistics = (
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user