Skip to content

Commit 2b608bf

Browse files
authored
Remove name from Shelly RGBCCT sensors (home-assistant#157492)
1 parent 972ed4b commit 2b608bf

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

homeassistant/components/shelly/sensor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@ def __init__(
525525
"power_rgbcct": RpcSensorDescription(
526526
key="rgbcct",
527527
sub_key="apower",
528-
name="Power",
529528
native_unit_of_measurement=UnitOfPower.WATT,
530529
device_class=SensorDeviceClass.POWER,
531530
state_class=SensorStateClass.MEASUREMENT,
@@ -963,7 +962,6 @@ def __init__(
963962
"energy_rgbcct": RpcSensorDescription(
964963
key="rgbcct",
965964
sub_key="aenergy",
966-
name="Energy",
967965
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
968966
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
969967
value=lambda status, _: status["total"],

tests/components/shelly/test_sensor.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,3 +2136,46 @@ async def test_shelly_irrigation_weather_sensors(
21362136
for entity in ("average_temperature", "rainfall"):
21372137
entity_id = f"{SENSOR_DOMAIN}.test_name_{entity}"
21382138
assert hass.states.get(entity_id) is None
2139+
2140+
2141+
async def test_rpc_rgbcct_sensors(
2142+
hass: HomeAssistant,
2143+
entity_registry: EntityRegistry,
2144+
mock_rpc_device: Mock,
2145+
monkeypatch: pytest.MonkeyPatch,
2146+
) -> None:
2147+
"""Test sensors for RGBCCT light."""
2148+
config = deepcopy(mock_rpc_device.config)
2149+
config["rgbcct:0"] = {"id": 0}
2150+
monkeypatch.setattr(mock_rpc_device, "config", config)
2151+
2152+
status = deepcopy(mock_rpc_device.status)
2153+
status["rgbcct:0"] = {
2154+
"aenergy": {"total": 45.141},
2155+
"apower": 12.2,
2156+
}
2157+
monkeypatch.setattr(mock_rpc_device, "status", status)
2158+
2159+
await init_integration(hass, 2)
2160+
2161+
entity_id = "sensor.test_name_power"
2162+
2163+
assert (state := hass.states.get(entity_id))
2164+
assert state.state == "12.2"
2165+
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
2166+
2167+
assert (entry := entity_registry.async_get(entity_id))
2168+
assert entry.unique_id == "123456789ABC-rgbcct:0-power_rgbcct"
2169+
assert entry.name is None
2170+
assert entry.translation_key is None # entity with device class and no channel name
2171+
2172+
entity_id = "sensor.test_name_energy"
2173+
2174+
assert (state := hass.states.get(entity_id))
2175+
assert state.state == "0.045141"
2176+
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfEnergy.KILO_WATT_HOUR
2177+
2178+
assert (entry := entity_registry.async_get(entity_id))
2179+
assert entry.unique_id == "123456789ABC-rgbcct:0-energy_rgbcct"
2180+
assert entry.name is None
2181+
assert entry.translation_key is None # entity with device class and no channel name

0 commit comments

Comments
 (0)