From 60604f79055a755771e8ab2951e86c0475caa73b Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 9 Jan 2023 12:09:32 +0100 Subject: [PATCH] Default disable voltage sensors in Plugwise (#85451) --- homeassistant/components/plugwise/sensor.py | 3 +++ tests/components/plugwise/test_sensor.py | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index 34dbd423e59..c9d1c4dc014 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -268,6 +268,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( device_class=SensorDeviceClass.VOLTAGE, native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, ), SensorEntityDescription( key="voltage_phase_two", @@ -275,6 +276,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( device_class=SensorDeviceClass.VOLTAGE, native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, ), SensorEntityDescription( key="voltage_phase_three", @@ -282,6 +284,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( device_class=SensorDeviceClass.VOLTAGE, native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, ), SensorEntityDescription( key="gas_consumed_interval", diff --git a/tests/components/plugwise/test_sensor.py b/tests/components/plugwise/test_sensor.py index 4ccb0b97bb2..0c7483c19bd 100644 --- a/tests/components/plugwise/test_sensor.py +++ b/tests/components/plugwise/test_sensor.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_component import async_update_entity +from homeassistant.helpers.entity_registry import async_get from tests.common import MockConfigEntry @@ -110,18 +111,21 @@ async def test_p1_3ph_dsmr_sensor_entities( assert state assert float(state.state) == 2080.0 + entity_id = "sensor.p1_voltage_phase_one" + state = hass.states.get(entity_id) + assert not state + + entity_registry = async_get(hass) + entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None) + await hass.async_block_till_done() + + await hass.config_entries.async_reload(init_integration.entry_id) + await hass.async_block_till_done() + 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