Update pvo to 2.1.0 (#103551)
parent
b372a64057
commit
9a776d958c
|
@ -1,7 +1,6 @@
|
|||
"""Diagnostics support for PVOutput."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -16,6 +15,4 @@ async def async_get_config_entry_diagnostics(
|
|||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: PVOutputDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
# Round-trip via JSON to trigger serialization
|
||||
data: dict[str, Any] = json.loads(coordinator.data.json())
|
||||
return data
|
||||
return coordinator.data.to_dict()
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
"integration_type": "device",
|
||||
"iot_class": "cloud_polling",
|
||||
"quality_scale": "platinum",
|
||||
"requirements": ["pvo==2.0.0"]
|
||||
"requirements": ["pvo==2.1.0"]
|
||||
}
|
||||
|
|
|
@ -1509,7 +1509,7 @@ pushbullet.py==0.11.0
|
|||
pushover_complete==1.1.1
|
||||
|
||||
# homeassistant.components.pvoutput
|
||||
pvo==2.0.0
|
||||
pvo==2.1.0
|
||||
|
||||
# homeassistant.components.canary
|
||||
py-canary==0.5.3
|
||||
|
|
|
@ -1154,7 +1154,7 @@ pushbullet.py==0.11.0
|
|||
pushover_complete==1.1.1
|
||||
|
||||
# homeassistant.components.pvoutput
|
||||
pvo==2.0.0
|
||||
pvo==2.1.0
|
||||
|
||||
# homeassistant.components.canary
|
||||
py-canary==0.5.3
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.pvoutput.const import CONF_SYSTEM_ID, DOMAIN
|
|||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -46,29 +46,16 @@ def mock_pvoutput_config_flow() -> Generator[None, MagicMock, None]:
|
|||
@pytest.fixture
|
||||
def mock_pvoutput() -> Generator[None, MagicMock, None]:
|
||||
"""Return a mocked PVOutput client."""
|
||||
status = Status(
|
||||
reported_date="20211229",
|
||||
reported_time="22:37",
|
||||
energy_consumption=1000,
|
||||
energy_generation=500,
|
||||
normalized_output=0.5,
|
||||
power_consumption=2500,
|
||||
power_generation=1500,
|
||||
temperature=20.2,
|
||||
voltage=220.5,
|
||||
)
|
||||
|
||||
system = System(
|
||||
inverter_brand="Super Inverters Inc.",
|
||||
system_name="Frenck's Solar Farm",
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.pvoutput.coordinator.PVOutput", autospec=True
|
||||
) as pvoutput_mock:
|
||||
pvoutput = pvoutput_mock.return_value
|
||||
pvoutput.status.return_value = status
|
||||
pvoutput.system.return_value = system
|
||||
pvoutput.status.return_value = Status.from_dict(
|
||||
load_json_object_fixture("status.json", DOMAIN)
|
||||
)
|
||||
pvoutput.system.return_value = System.from_dict(
|
||||
load_json_object_fixture("system.json", DOMAIN)
|
||||
)
|
||||
yield pvoutput
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"energy_consumption": 1000,
|
||||
"energy_generation": 500,
|
||||
"normalized_output": 0.5,
|
||||
"power_consumption": 2500,
|
||||
"power_generation": 1500,
|
||||
"reported_date": "20210101",
|
||||
"reported_time": "22:37",
|
||||
"temperature": 20.2,
|
||||
"voltage": 220.5
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"array_tilt": 30,
|
||||
"install_date": "20210101",
|
||||
"inverter_brand": "Super Inverters Inc.",
|
||||
"inverter_power": 5000,
|
||||
"inverters": 1,
|
||||
"latitude": 52.0,
|
||||
"longitude": 4.0,
|
||||
"orientation": "N",
|
||||
"panel_brand": "Super Panels Inc.",
|
||||
"panel_power": 250,
|
||||
"panels": 20,
|
||||
"shade": 0.1,
|
||||
"status_interval": 5,
|
||||
"system_name": "Frenck's Solar Farm",
|
||||
"system_size": 5,
|
||||
"zipcode": 1234
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
# serializer version: 1
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'energy_consumption': 1000.0,
|
||||
'energy_generation': 500.0,
|
||||
'normalized_output': 0.5,
|
||||
'power_consumption': 2500.0,
|
||||
'power_generation': 1500.0,
|
||||
'reported_date': '20210101',
|
||||
'reported_time': '22:37:00',
|
||||
'temperature': 20.2,
|
||||
'voltage': 220.5,
|
||||
})
|
||||
# ---
|
|
@ -1,5 +1,7 @@
|
|||
"""Tests for the diagnostics data provided by the PVOutput integration."""
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -11,18 +13,10 @@ async def test_diagnostics(
|
|||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
init_integration: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, init_integration
|
||||
) == {
|
||||
"energy_consumption": 1000,
|
||||
"energy_generation": 500,
|
||||
"normalized_output": 0.5,
|
||||
"power_consumption": 2500,
|
||||
"power_generation": 1500,
|
||||
"reported_date": "2021-12-29",
|
||||
"reported_time": "22:37:00",
|
||||
"temperature": 20.2,
|
||||
"voltage": 220.5,
|
||||
}
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||
== snapshot
|
||||
)
|
||||
|
|
|
@ -35,7 +35,7 @@ async def test_sensors(
|
|||
assert state
|
||||
assert entry.unique_id == "12345_energy_consumption"
|
||||
assert entry.entity_category is None
|
||||
assert state.state == "1000"
|
||||
assert state.state == "1000.0"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
|
@ -51,7 +51,7 @@ async def test_sensors(
|
|||
assert state
|
||||
assert entry.unique_id == "12345_energy_generation"
|
||||
assert entry.entity_category is None
|
||||
assert state.state == "500"
|
||||
assert state.state == "500.0"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
|
@ -83,7 +83,7 @@ async def test_sensors(
|
|||
assert state
|
||||
assert entry.unique_id == "12345_power_consumption"
|
||||
assert entry.entity_category is None
|
||||
assert state.state == "2500"
|
||||
assert state.state == "2500.0"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Power consumed"
|
||||
|
@ -98,7 +98,7 @@ async def test_sensors(
|
|||
assert state
|
||||
assert entry.unique_id == "12345_power_generation"
|
||||
assert entry.entity_category is None
|
||||
assert state.state == "1500"
|
||||
assert state.state == "1500.0"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
|
|
Loading…
Reference in New Issue