diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index 11ed720b51c..f0fc475e0db 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -139,6 +139,13 @@ SENSOR_ENTITIES: dict[str, SensorEntityDescription] = { device_class=SensorDeviceClass.CURRENT, entity_registry_enabled_default=False, ), + "pv_isolation_resistance": SensorEntityDescription( + key="pv_isolation_resistance", + name="PV Isolation Resistance", + native_unit_of_measurement="kOhms", + state_class=SensorStateClass.MEASUREMENT, + entity_registry_enabled_default=False, + ), "insulation_residual_current": SensorEntityDescription( key="insulation_residual_current", name="Insulation Residual Current", @@ -147,6 +154,13 @@ SENSOR_ENTITIES: dict[str, SensorEntityDescription] = { device_class=SensorDeviceClass.CURRENT, entity_registry_enabled_default=False, ), + "pv_power": SensorEntityDescription( + key="pv_power", + name="PV Power", + native_unit_of_measurement=UnitOfPower.WATT, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.POWER, + ), "grid_power": SensorEntityDescription( key="grid_power", name="Grid Power", @@ -479,6 +493,30 @@ SENSOR_ENTITIES: dict[str, SensorEntityDescription] = { state_class=SensorStateClass.TOTAL_INCREASING, device_class=SensorDeviceClass.ENERGY, ), + "sps_voltage": SensorEntityDescription( + key="sps_voltage", + name="Secure Power Supply Voltage", + native_unit_of_measurement=UnitOfElectricPotential.VOLT, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + entity_registry_enabled_default=False, + ), + "sps_current": SensorEntityDescription( + key="sps_current", + name="Secure Power Supply Current", + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.CURRENT, + entity_registry_enabled_default=False, + ), + "sps_power": SensorEntityDescription( + key="sps_power", + name="Secure Power Supply Power", + native_unit_of_measurement=UnitOfPower.WATT, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.POWER, + entity_registry_enabled_default=False, + ), "optimizer_power": SensorEntityDescription( key="optimizer_power", name="Optimizer Power", diff --git a/tests/components/sma/test_sensor.py b/tests/components/sma/test_sensor.py index a79588f4800..acc26a8bf90 100644 --- a/tests/components/sma/test_sensor.py +++ b/tests/components/sma/test_sensor.py @@ -1,4 +1,12 @@ """Test the sma sensor platform.""" +from pysma.const import ( + ENERGY_METER_VIA_INVERTER, + GENERIC_SENSORS, + OPTIMIZERS_VIA_INVERTER, +) +from pysma.definitions import sensor_map + +from homeassistant.components.sma.sensor import SENSOR_ENTITIES from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, UnitOfPower from homeassistant.core import HomeAssistant @@ -8,3 +16,15 @@ async def test_sensors(hass: HomeAssistant, init_integration) -> None: state = hass.states.get("sensor.sma_device_grid_power") assert state assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT + + +async def test_sensor_entities(hass: HomeAssistant, init_integration) -> None: + """Test SENSOR_ENTITIES contains a SensorEntityDescription for each pysma sensor.""" + pysma_sensor_definitions = ( + sensor_map[GENERIC_SENSORS] + + sensor_map[OPTIMIZERS_VIA_INVERTER] + + sensor_map[ENERGY_METER_VIA_INVERTER] + ) + + for sensor in pysma_sensor_definitions: + assert sensor.name in SENSOR_ENTITIES