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