@@ -98,7 +98,7 @@ async def test_light_turn_on(
9898 """Test light entity turn on."""
9999
100100 light ._api = ufp .api
101- light .api .set_light_is_led_force_on = AsyncMock ()
101+ light .api .update_light_public = AsyncMock ()
102102
103103 await init_entry (hass , ufp , [light , unadopted_light ])
104104 assert_entity_counts (hass , Platform .LIGHT , 1 , 1 )
@@ -108,8 +108,36 @@ async def test_light_turn_on(
108108 "light" , "turn_on" , {ATTR_ENTITY_ID : entity_id }, blocking = True
109109 )
110110
111- assert light .api .set_light_is_led_force_on .called
112- assert light .api .set_light_is_led_force_on .call_args == ((light .id , True ),)
111+ assert light .api .update_light_public .called
112+ light .api .update_light_public .assert_called_once_with (
113+ light .id , is_light_force_enabled = True , light_device_settings = None
114+ )
115+
116+
117+ async def test_light_turn_on_with_brightness (
118+ hass : HomeAssistant , ufp : MockUFPFixture , light : Light , unadopted_light : Light
119+ ) -> None :
120+ """Test light entity turn on with brightness."""
121+
122+ light ._api = ufp .api
123+ light .api .update_light_public = AsyncMock ()
124+
125+ await init_entry (hass , ufp , [light , unadopted_light ])
126+ assert_entity_counts (hass , Platform .LIGHT , 1 , 1 )
127+
128+ entity_id = "light.test_light"
129+ await hass .services .async_call (
130+ "light" ,
131+ "turn_on" ,
132+ {ATTR_ENTITY_ID : entity_id , ATTR_BRIGHTNESS : 128 },
133+ blocking = True ,
134+ )
135+
136+ assert light .api .update_light_public .called
137+ call_kwargs = light .api .update_light_public .call_args [1 ]
138+ assert call_kwargs ["is_light_force_enabled" ] is True
139+ assert call_kwargs ["light_device_settings" ] is not None
140+ assert call_kwargs ["light_device_settings" ].led_level == 3 # 128/255 * 6 ≈ 3
113141
114142
115143async def test_light_turn_off (
@@ -118,7 +146,7 @@ async def test_light_turn_off(
118146 """Test light entity turn off."""
119147
120148 light ._api = ufp .api
121- light .api .set_light_is_led_force_on = AsyncMock ()
149+ light .api .update_light_public = AsyncMock ()
122150
123151 await init_entry (hass , ufp , [light , unadopted_light ])
124152 assert_entity_counts (hass , Platform .LIGHT , 1 , 1 )
@@ -128,5 +156,7 @@ async def test_light_turn_off(
128156 "light" , "turn_off" , {ATTR_ENTITY_ID : entity_id }, blocking = True
129157 )
130158
131- assert light .api .set_light_is_led_force_on .called
132- assert light .api .set_light_is_led_force_on .call_args == ((light .id , False ),)
159+ assert light .api .update_light_public .called
160+ light .api .update_light_public .assert_called_once_with (
161+ light .id , is_light_force_enabled = False
162+ )
0 commit comments