@@ -1847,6 +1847,60 @@ async def test_supports_transition_template(
18471847 ) != expected_value
18481848
18491849
1850+ @pytest .mark .parametrize ("count" , [1 ])
1851+ async def test_supports_transition_template_updates (
1852+ hass : HomeAssistant , count : int
1853+ ) -> None :
1854+ """Test the template for the supports transition dynamically."""
1855+ light_config = {
1856+ "test_template_light" : {
1857+ "value_template" : "{{ 1 == 1 }}" ,
1858+ "turn_on" : {"service" : "light.turn_on" , "entity_id" : "light.test_state" },
1859+ "turn_off" : {"service" : "light.turn_off" , "entity_id" : "light.test_state" },
1860+ "set_temperature" : {
1861+ "service" : "light.turn_on" ,
1862+ "data_template" : {
1863+ "entity_id" : "light.test_state" ,
1864+ "color_temp" : "{{color_temp}}" ,
1865+ },
1866+ },
1867+ "set_effect" : {
1868+ "service" : "test.automation" ,
1869+ "data_template" : {
1870+ "entity_id" : "test.test_state" ,
1871+ "effect" : "{{effect}}" ,
1872+ },
1873+ },
1874+ "effect_list_template" : "{{ ['Disco', 'Police'] }}" ,
1875+ "effect_template" : "{{ None }}" ,
1876+ "supports_transition_template" : "{{ states('sensor.test') }}" ,
1877+ }
1878+ }
1879+ await async_setup_light (hass , count , light_config )
1880+ state = hass .states .get ("light.test_template_light" )
1881+ assert state is not None
1882+
1883+ hass .states .async_set ("sensor.test" , 0 )
1884+ await hass .async_block_till_done ()
1885+ state = hass .states .get ("light.test_template_light" )
1886+ supported_features = state .attributes .get ("supported_features" )
1887+ assert supported_features == LightEntityFeature .EFFECT
1888+
1889+ hass .states .async_set ("sensor.test" , 1 )
1890+ await hass .async_block_till_done ()
1891+ state = hass .states .get ("light.test_template_light" )
1892+ supported_features = state .attributes .get ("supported_features" )
1893+ assert (
1894+ supported_features == LightEntityFeature .TRANSITION | LightEntityFeature .EFFECT
1895+ )
1896+
1897+ hass .states .async_set ("sensor.test" , 0 )
1898+ await hass .async_block_till_done ()
1899+ state = hass .states .get ("light.test_template_light" )
1900+ supported_features = state .attributes .get ("supported_features" )
1901+ assert supported_features == LightEntityFeature .EFFECT
1902+
1903+
18501904@pytest .mark .parametrize ("count" , [1 ])
18511905@pytest .mark .parametrize (
18521906 "light_config" ,
0 commit comments