mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Update pvo to 2.1.0 (#103551)
This commit is contained in:
parent
b372a64057
commit
9a776d958c
@ -1,7 +1,6 @@
|
|||||||
"""Diagnostics support for PVOutput."""
|
"""Diagnostics support for PVOutput."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -16,6 +15,4 @@ async def async_get_config_entry_diagnostics(
|
|||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
coordinator: PVOutputDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator: PVOutputDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
# Round-trip via JSON to trigger serialization
|
return coordinator.data.to_dict()
|
||||||
data: dict[str, Any] = json.loads(coordinator.data.json())
|
|
||||||
return data
|
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
"integration_type": "device",
|
"integration_type": "device",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"quality_scale": "platinum",
|
"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
|
pushover_complete==1.1.1
|
||||||
|
|
||||||
# homeassistant.components.pvoutput
|
# homeassistant.components.pvoutput
|
||||||
pvo==2.0.0
|
pvo==2.1.0
|
||||||
|
|
||||||
# homeassistant.components.canary
|
# homeassistant.components.canary
|
||||||
py-canary==0.5.3
|
py-canary==0.5.3
|
||||||
|
@ -1154,7 +1154,7 @@ pushbullet.py==0.11.0
|
|||||||
pushover_complete==1.1.1
|
pushover_complete==1.1.1
|
||||||
|
|
||||||
# homeassistant.components.pvoutput
|
# homeassistant.components.pvoutput
|
||||||
pvo==2.0.0
|
pvo==2.1.0
|
||||||
|
|
||||||
# homeassistant.components.canary
|
# homeassistant.components.canary
|
||||||
py-canary==0.5.3
|
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.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -46,29 +46,16 @@ def mock_pvoutput_config_flow() -> Generator[None, MagicMock, None]:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_pvoutput() -> Generator[None, MagicMock, None]:
|
def mock_pvoutput() -> Generator[None, MagicMock, None]:
|
||||||
"""Return a mocked PVOutput client."""
|
"""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(
|
with patch(
|
||||||
"homeassistant.components.pvoutput.coordinator.PVOutput", autospec=True
|
"homeassistant.components.pvoutput.coordinator.PVOutput", autospec=True
|
||||||
) as pvoutput_mock:
|
) as pvoutput_mock:
|
||||||
pvoutput = pvoutput_mock.return_value
|
pvoutput = pvoutput_mock.return_value
|
||||||
pvoutput.status.return_value = status
|
pvoutput.status.return_value = Status.from_dict(
|
||||||
pvoutput.system.return_value = system
|
load_json_object_fixture("status.json", DOMAIN)
|
||||||
|
)
|
||||||
|
pvoutput.system.return_value = System.from_dict(
|
||||||
|
load_json_object_fixture("system.json", DOMAIN)
|
||||||
|
)
|
||||||
yield pvoutput
|
yield pvoutput
|
||||||
|
|
||||||
|
|
||||||
|
11
tests/components/pvoutput/fixtures/status.json
Normal file
11
tests/components/pvoutput/fixtures/status.json
Normal file
@ -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
|
||||||
|
}
|
18
tests/components/pvoutput/fixtures/system.json
Normal file
18
tests/components/pvoutput/fixtures/system.json
Normal file
@ -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
|
||||||
|
}
|
14
tests/components/pvoutput/snapshots/test_diagnostics.ambr
Normal file
14
tests/components/pvoutput/snapshots/test_diagnostics.ambr
Normal file
@ -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."""
|
"""Tests for the diagnostics data provided by the PVOutput integration."""
|
||||||
|
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
@ -11,18 +13,10 @@ async def test_diagnostics(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
init_integration: MockConfigEntry,
|
init_integration: MockConfigEntry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test diagnostics."""
|
"""Test diagnostics."""
|
||||||
assert await get_diagnostics_for_config_entry(
|
assert (
|
||||||
hass, hass_client, init_integration
|
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||||
) == {
|
== snapshot
|
||||||
"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,
|
|
||||||
}
|
|
||||||
|
@ -35,7 +35,7 @@ async def test_sensors(
|
|||||||
assert state
|
assert state
|
||||||
assert entry.unique_id == "12345_energy_consumption"
|
assert entry.unique_id == "12345_energy_consumption"
|
||||||
assert entry.entity_category is None
|
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_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
@ -51,7 +51,7 @@ async def test_sensors(
|
|||||||
assert state
|
assert state
|
||||||
assert entry.unique_id == "12345_energy_generation"
|
assert entry.unique_id == "12345_energy_generation"
|
||||||
assert entry.entity_category is None
|
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_DEVICE_CLASS) == SensorDeviceClass.ENERGY
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
@ -83,7 +83,7 @@ async def test_sensors(
|
|||||||
assert state
|
assert state
|
||||||
assert entry.unique_id == "12345_power_consumption"
|
assert entry.unique_id == "12345_power_consumption"
|
||||||
assert entry.entity_category is None
|
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_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Power consumed"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's Solar Farm Power consumed"
|
||||||
@ -98,7 +98,7 @@ async def test_sensors(
|
|||||||
assert state
|
assert state
|
||||||
assert entry.unique_id == "12345_power_generation"
|
assert entry.unique_id == "12345_power_generation"
|
||||||
assert entry.entity_category is None
|
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_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user