From 2b608bf15cc9ae4380c47da5066b9ed58f3fdc5d Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Mon, 1 Dec 2025 10:54:19 +0100 Subject: [PATCH] Remove `name` from Shelly RGBCCT sensors (#157492) --- homeassistant/components/shelly/sensor.py | 2 -- tests/components/shelly/test_sensor.py | 43 +++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index aa51fb1d443..4811879ab9d 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -525,7 +525,6 @@ RPC_SENSORS: Final = { "power_rgbcct": RpcSensorDescription( key="rgbcct", sub_key="apower", - name="Power", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, @@ -963,7 +962,6 @@ RPC_SENSORS: Final = { "energy_rgbcct": RpcSensorDescription( key="rgbcct", sub_key="aenergy", - name="Energy", native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, value=lambda status, _: status["total"], diff --git a/tests/components/shelly/test_sensor.py b/tests/components/shelly/test_sensor.py index 16d5fec55b4..56b24dec89a 100644 --- a/tests/components/shelly/test_sensor.py +++ b/tests/components/shelly/test_sensor.py @@ -2136,3 +2136,46 @@ async def test_shelly_irrigation_weather_sensors( for entity in ("average_temperature", "rainfall"): entity_id = f"{SENSOR_DOMAIN}.test_name_{entity}" assert hass.states.get(entity_id) is None + + +async def test_rpc_rgbcct_sensors( + hass: HomeAssistant, + entity_registry: EntityRegistry, + mock_rpc_device: Mock, + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Test sensors for RGBCCT light.""" + config = deepcopy(mock_rpc_device.config) + config["rgbcct:0"] = {"id": 0} + monkeypatch.setattr(mock_rpc_device, "config", config) + + status = deepcopy(mock_rpc_device.status) + status["rgbcct:0"] = { + "aenergy": {"total": 45.141}, + "apower": 12.2, + } + monkeypatch.setattr(mock_rpc_device, "status", status) + + await init_integration(hass, 2) + + entity_id = "sensor.test_name_power" + + assert (state := hass.states.get(entity_id)) + assert state.state == "12.2" + assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT + + assert (entry := entity_registry.async_get(entity_id)) + assert entry.unique_id == "123456789ABC-rgbcct:0-power_rgbcct" + assert entry.name is None + assert entry.translation_key is None # entity with device class and no channel name + + entity_id = "sensor.test_name_energy" + + assert (state := hass.states.get(entity_id)) + assert state.state == "0.045141" + assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR + + assert (entry := entity_registry.async_get(entity_id)) + assert entry.unique_id == "123456789ABC-rgbcct:0-energy_rgbcct" + assert entry.name is None + assert entry.translation_key is None # entity with device class and no channel name