diff --git a/homeassistant/components/plugwise/manifest.json b/homeassistant/components/plugwise/manifest.json index e10d86f2779..bdb1a475bcf 100644 --- a/homeassistant/components/plugwise/manifest.json +++ b/homeassistant/components/plugwise/manifest.json @@ -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, diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index 51cf27a2591..34dbd423e59 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -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", diff --git a/requirements_all.txt b/requirements_all.txt index 60d3e18d478..eec72027109 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 403f823dff6..6a1c463d2a7 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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 diff --git a/tests/components/plugwise/conftest.py b/tests/components/plugwise/conftest.py index 0c70a2bed6d..f0a114a3de4 100644 --- a/tests/components/plugwise/conftest.py +++ b/tests/components/plugwise/conftest.py @@ -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.""" diff --git a/tests/components/plugwise/fixtures/p1v4_3ph/all_data.json b/tests/components/plugwise/fixtures/p1v4_3ph/all_data.json new file mode 100644 index 00000000000..852ca2857cd --- /dev/null +++ b/tests/components/plugwise/fixtures/p1v4_3ph/all_data.json @@ -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 + } + } + } +] diff --git a/tests/components/plugwise/fixtures/p1v4_3ph/notifications.json b/tests/components/plugwise/fixtures/p1v4_3ph/notifications.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/tests/components/plugwise/fixtures/p1v4_3ph/notifications.json @@ -0,0 +1 @@ +{} diff --git a/tests/components/plugwise/test_sensor.py b/tests/components/plugwise/test_sensor.py index b08c2113d80..4ccb0b97bb2 100644 --- a/tests/components/plugwise/test_sensor.py +++ b/tests/components/plugwise/test_sensor.py @@ -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: