mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Remove name from Shelly RGBCCT sensors (#157492)
This commit is contained in:
@@ -525,7 +525,6 @@ RPC_SENSORS: Final = {
|
|||||||
"power_rgbcct": RpcSensorDescription(
|
"power_rgbcct": RpcSensorDescription(
|
||||||
key="rgbcct",
|
key="rgbcct",
|
||||||
sub_key="apower",
|
sub_key="apower",
|
||||||
name="Power",
|
|
||||||
native_unit_of_measurement=UnitOfPower.WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@@ -963,7 +962,6 @@ RPC_SENSORS: Final = {
|
|||||||
"energy_rgbcct": RpcSensorDescription(
|
"energy_rgbcct": RpcSensorDescription(
|
||||||
key="rgbcct",
|
key="rgbcct",
|
||||||
sub_key="aenergy",
|
sub_key="aenergy",
|
||||||
name="Energy",
|
|
||||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||||
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
value=lambda status, _: status["total"],
|
value=lambda status, _: status["total"],
|
||||||
|
|||||||
@@ -2136,3 +2136,46 @@ async def test_shelly_irrigation_weather_sensors(
|
|||||||
for entity in ("average_temperature", "rainfall"):
|
for entity in ("average_temperature", "rainfall"):
|
||||||
entity_id = f"{SENSOR_DOMAIN}.test_name_{entity}"
|
entity_id = f"{SENSOR_DOMAIN}.test_name_{entity}"
|
||||||
assert hass.states.get(entity_id) is None
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user