1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-20 02:48:57 +00:00

Remove name from Shelly RGBCCT sensors (#157492)

This commit is contained in:
Maciej Bieniek
2025-12-01 10:54:19 +01:00
committed by GitHub
parent 972ed4b27f
commit 2b608bf15c
2 changed files with 43 additions and 2 deletions

View File

@@ -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"],

View File

@@ -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