mirror of https://github.com/home-assistant/core
Plugwise: add support for 3-phase DSMR's (#85421)
* Bump plugwise to v0.27.0 * Add p1-3phase test-fixture * Add the new 3ph P1 DSMR sensors * Add p1 3ph test-case
This commit is contained in:
parent
2a965a6e44
commit
5eb7aed0ca
|
@ -2,7 +2,7 @@
|
|||
"domain": "plugwise",
|
||||
"name": "Plugwise",
|
||||
"documentation": "https://www.home-assistant.io/integrations/plugwise",
|
||||
"requirements": ["plugwise==0.25.14"],
|
||||
"requirements": ["plugwise==0.27.0"],
|
||||
"codeowners": ["@CoMPaTech", "@bouwew", "@brefra", "@frenck"],
|
||||
"zeroconf": ["_plugwise._tcp.local."],
|
||||
"config_flow": true,
|
||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
UnitOfPressure,
|
||||
|
@ -219,6 +220,69 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="electricity_phase_one_consumed",
|
||||
name="Electricity phase one consumed",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="electricity_phase_two_consumed",
|
||||
name="Electricity phase two consumed",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="electricity_phase_three_consumed",
|
||||
name="Electricity phase three consumed",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="electricity_phase_one_produced",
|
||||
name="Electricity phase one produced",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="electricity_phase_two_produced",
|
||||
name="Electricity phase two produced",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="electricity_phase_three_produced",
|
||||
name="Electricity phase three produced",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_phase_one",
|
||||
name="Voltage phase one",
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_phase_two",
|
||||
name="Voltage phase two",
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_phase_three",
|
||||
name="Voltage phase three",
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="gas_consumed_interval",
|
||||
name="Gas consumed interval",
|
||||
|
|
|
@ -1361,7 +1361,7 @@ plexauth==0.0.6
|
|||
plexwebsocket==0.0.13
|
||||
|
||||
# homeassistant.components.plugwise
|
||||
plugwise==0.25.14
|
||||
plugwise==0.27.0
|
||||
|
||||
# homeassistant.components.plum_lightpad
|
||||
plumlightpad==0.0.11
|
||||
|
|
|
@ -988,7 +988,7 @@ plexauth==0.0.6
|
|||
plexwebsocket==0.0.13
|
||||
|
||||
# homeassistant.components.plugwise
|
||||
plugwise==0.25.14
|
||||
plugwise==0.27.0
|
||||
|
||||
# homeassistant.components.plum_lightpad
|
||||
plumlightpad==0.0.11
|
||||
|
|
|
@ -247,6 +247,31 @@ def mock_smile_p1() -> Generator[None, MagicMock, None]:
|
|||
yield smile
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_smile_p1_2() -> Generator[None, MagicMock, None]:
|
||||
"""Create a Mock P1 3-phase DSMR environment for testing exceptions."""
|
||||
chosen_env = "p1v4_3ph"
|
||||
with patch(
|
||||
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
|
||||
) as smile_mock:
|
||||
smile = smile_mock.return_value
|
||||
|
||||
smile.gateway_id = "03e65b16e4b247a29ae0d75a78cb492e"
|
||||
smile.heater_id = None
|
||||
smile.smile_version = "4.4.2"
|
||||
smile.smile_type = "power"
|
||||
smile.smile_hostname = "smile98765"
|
||||
smile.smile_model = "Gateway"
|
||||
smile.smile_name = "Smile P1"
|
||||
|
||||
smile.connect.return_value = True
|
||||
|
||||
smile.notifications = _read_json(chosen_env, "notifications")
|
||||
smile.async_update.return_value = _read_json(chosen_env, "all_data")
|
||||
|
||||
yield smile
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_stretch() -> Generator[None, MagicMock, None]:
|
||||
"""Create a Mock Stretch environment for testing exceptions."""
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
[
|
||||
{
|
||||
"smile_name": "Smile P1",
|
||||
"gateway_id": "03e65b16e4b247a29ae0d75a78cb492e",
|
||||
"notifications": {}
|
||||
},
|
||||
{
|
||||
"03e65b16e4b247a29ae0d75a78cb492e": {
|
||||
"dev_class": "gateway",
|
||||
"firmware": "4.4.2",
|
||||
"hardware": "AME Smile 2.0 board",
|
||||
"location": "03e65b16e4b247a29ae0d75a78cb492e",
|
||||
"mac_address": "012345670001",
|
||||
"model": "Gateway",
|
||||
"name": "Smile P1",
|
||||
"vendor": "Plugwise",
|
||||
"binary_sensors": {
|
||||
"plugwise_notification": false
|
||||
}
|
||||
},
|
||||
"b82b6b3322484f2ea4e25e0bd5f3d61f": {
|
||||
"dev_class": "smartmeter",
|
||||
"location": "03e65b16e4b247a29ae0d75a78cb492e",
|
||||
"model": "XMX5LGF0010453051839",
|
||||
"name": "P1",
|
||||
"vendor": "XEMEX NV",
|
||||
"available": true,
|
||||
"sensors": {
|
||||
"net_electricity_point": 5553,
|
||||
"electricity_consumed_peak_point": 0,
|
||||
"electricity_consumed_off_peak_point": 5553,
|
||||
"net_electricity_cumulative": 231866.539,
|
||||
"electricity_consumed_peak_cumulative": 161328.641,
|
||||
"electricity_consumed_off_peak_cumulative": 70537.898,
|
||||
"electricity_consumed_peak_interval": 0,
|
||||
"electricity_consumed_off_peak_interval": 314,
|
||||
"electricity_produced_peak_point": 0,
|
||||
"electricity_produced_off_peak_point": 0,
|
||||
"electricity_produced_peak_cumulative": 0.0,
|
||||
"electricity_produced_off_peak_cumulative": 0.0,
|
||||
"electricity_produced_peak_interval": 0,
|
||||
"electricity_produced_off_peak_interval": 0,
|
||||
"electricity_phase_one_consumed": 1763,
|
||||
"electricity_phase_two_consumed": 1703,
|
||||
"electricity_phase_three_consumed": 2080,
|
||||
"electricity_phase_one_produced": 0,
|
||||
"electricity_phase_two_produced": 0,
|
||||
"electricity_phase_three_produced": 0,
|
||||
"gas_consumed_cumulative": 16811.37,
|
||||
"gas_consumed_interval": 0.06,
|
||||
"voltage_phase_one": 233.2,
|
||||
"voltage_phase_two": 234.4,
|
||||
"voltage_phase_three": 234.7
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -94,6 +94,35 @@ async def test_p1_dsmr_sensor_entities(
|
|||
assert float(state.state) == 584.85
|
||||
|
||||
|
||||
async def test_p1_3ph_dsmr_sensor_entities(
|
||||
hass: HomeAssistant, mock_smile_p1_2: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test creation of power related sensor entities."""
|
||||
state = hass.states.get("sensor.p1_electricity_phase_one_consumed")
|
||||
assert state
|
||||
assert float(state.state) == 1763.0
|
||||
|
||||
state = hass.states.get("sensor.p1_electricity_phase_two_consumed")
|
||||
assert state
|
||||
assert float(state.state) == 1703.0
|
||||
|
||||
state = hass.states.get("sensor.p1_electricity_phase_three_consumed")
|
||||
assert state
|
||||
assert float(state.state) == 2080.0
|
||||
|
||||
state = hass.states.get("sensor.p1_voltage_phase_one")
|
||||
assert state
|
||||
assert float(state.state) == 233.2
|
||||
|
||||
state = hass.states.get("sensor.p1_voltage_phase_two")
|
||||
assert state
|
||||
assert float(state.state) == 234.4
|
||||
|
||||
state = hass.states.get("sensor.p1_voltage_phase_three")
|
||||
assert state
|
||||
assert float(state.state) == 234.7
|
||||
|
||||
|
||||
async def test_stretch_sensor_entities(
|
||||
hass: HomeAssistant, mock_stretch: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
|
|
Loading…
Reference in New Issue