Use direct service calls in light platform tests (#40604)

This commit is contained in:
Franck Nijhof 2020-09-26 13:19:59 +02:00 committed by GitHub
parent c64eec3238
commit c011f3fa95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ from homeassistant.components import light
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
CONF_PLATFORM, CONF_PLATFORM,
ENTITY_MATCH_ALL,
SERVICE_TOGGLE, SERVICE_TOGGLE,
SERVICE_TURN_OFF, SERVICE_TURN_OFF,
SERVICE_TURN_ON, SERVICE_TURN_ON,
@ -22,7 +23,6 @@ from homeassistant.setup import async_setup_component
import tests.async_mock as mock import tests.async_mock as mock
from tests.common import async_mock_service from tests.common import async_mock_service
from tests.components.light import common
@pytest.fixture @pytest.fixture
@ -47,20 +47,22 @@ async def test_methods(hass):
# Test turn_on # Test turn_on
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON) turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
await common.async_turn_on( await hass.services.async_call(
hass, light.DOMAIN,
entity_id="entity_id_val", SERVICE_TURN_ON,
transition="transition_val", {
brightness="brightness_val", ATTR_ENTITY_ID: "entity_id_val",
rgb_color="rgb_color_val", light.ATTR_TRANSITION: "transition_val",
xy_color="xy_color_val", light.ATTR_BRIGHTNESS: "brightness_val",
profile="profile_val", light.ATTR_RGB_COLOR: "rgb_color_val",
color_name="color_name_val", light.ATTR_XY_COLOR: "xy_color_val",
white_value="white_val", light.ATTR_PROFILE: "profile_val",
light.ATTR_COLOR_NAME: "color_name_val",
light.ATTR_WHITE_VALUE: "white_val",
},
blocking=True,
) )
await hass.async_block_till_done()
assert len(turn_on_calls) == 1 assert len(turn_on_calls) == 1
call = turn_on_calls[-1] call = turn_on_calls[-1]
@ -78,29 +80,34 @@ async def test_methods(hass):
# Test turn_off # Test turn_off
turn_off_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_OFF) turn_off_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_OFF)
await common.async_turn_off( await hass.services.async_call(
hass, entity_id="entity_id_val", transition="transition_val" light.DOMAIN,
SERVICE_TURN_OFF,
{
ATTR_ENTITY_ID: "entity_id_val",
light.ATTR_TRANSITION: "transition_val",
},
blocking=True,
) )
await hass.async_block_till_done()
assert len(turn_off_calls) == 1 assert len(turn_off_calls) == 1
call = turn_off_calls[-1] call = turn_off_calls[-1]
assert light.DOMAIN == call.domain assert call.domain == light.DOMAIN
assert SERVICE_TURN_OFF == call.service assert call.service == SERVICE_TURN_OFF
assert call.data[ATTR_ENTITY_ID] == "entity_id_val" assert call.data[ATTR_ENTITY_ID] == "entity_id_val"
assert call.data[light.ATTR_TRANSITION] == "transition_val" assert call.data[light.ATTR_TRANSITION] == "transition_val"
# Test toggle # Test toggle
toggle_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TOGGLE) toggle_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TOGGLE)
await common.async_toggle( await hass.services.async_call(
hass, entity_id="entity_id_val", transition="transition_val" light.DOMAIN,
SERVICE_TOGGLE,
{ATTR_ENTITY_ID: "entity_id_val", light.ATTR_TRANSITION: "transition_val"},
blocking=True,
) )
await hass.async_block_till_done()
assert len(toggle_calls) == 1 assert len(toggle_calls) == 1
call = toggle_calls[-1] call = toggle_calls[-1]
@ -128,186 +135,287 @@ async def test_services(hass):
assert not light.is_on(hass, ent3.entity_id) assert not light.is_on(hass, ent3.entity_id)
# Test basic turn_on, turn_off, toggle services # Test basic turn_on, turn_off, toggle services
await common.async_turn_off(hass, entity_id=ent1.entity_id) await hass.services.async_call(
await common.async_turn_on(hass, entity_id=ent2.entity_id) light.DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ent1.entity_id}, blocking=True
)
await hass.async_block_till_done() await hass.services.async_call(
light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ent2.entity_id}, blocking=True
)
assert not light.is_on(hass, ent1.entity_id) assert not light.is_on(hass, ent1.entity_id)
assert light.is_on(hass, ent2.entity_id) assert light.is_on(hass, ent2.entity_id)
# turn on all lights # turn on all lights
await common.async_turn_on(hass) await hass.services.async_call(
light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True
await hass.async_block_till_done() )
assert light.is_on(hass, ent1.entity_id) assert light.is_on(hass, ent1.entity_id)
assert light.is_on(hass, ent2.entity_id) assert light.is_on(hass, ent2.entity_id)
assert light.is_on(hass, ent3.entity_id) assert light.is_on(hass, ent3.entity_id)
# turn off all lights # turn off all lights
await common.async_turn_off(hass) await hass.services.async_call(
light.DOMAIN,
await hass.async_block_till_done() SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: ENTITY_MATCH_ALL},
blocking=True,
)
assert not light.is_on(hass, ent1.entity_id) assert not light.is_on(hass, ent1.entity_id)
assert not light.is_on(hass, ent2.entity_id) assert not light.is_on(hass, ent2.entity_id)
assert not light.is_on(hass, ent3.entity_id) assert not light.is_on(hass, ent3.entity_id)
# turn off all lights by setting brightness to 0 # turn off all lights by setting brightness to 0
await common.async_turn_on(hass) await hass.services.async_call(
await hass.async_block_till_done() light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True
)
await common.async_turn_on(hass, brightness=0) await hass.services.async_call(
await hass.async_block_till_done() light.DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ENTITY_MATCH_ALL, light.ATTR_BRIGHTNESS: 0},
blocking=True,
)
assert not light.is_on(hass, ent1.entity_id) assert not light.is_on(hass, ent1.entity_id)
assert not light.is_on(hass, ent2.entity_id) assert not light.is_on(hass, ent2.entity_id)
assert not light.is_on(hass, ent3.entity_id) assert not light.is_on(hass, ent3.entity_id)
# toggle all lights # toggle all lights
await common.async_toggle(hass) await hass.services.async_call(
light.DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True
await hass.async_block_till_done() )
assert light.is_on(hass, ent1.entity_id) assert light.is_on(hass, ent1.entity_id)
assert light.is_on(hass, ent2.entity_id) assert light.is_on(hass, ent2.entity_id)
assert light.is_on(hass, ent3.entity_id) assert light.is_on(hass, ent3.entity_id)
# toggle all lights # toggle all lights
await common.async_toggle(hass) await hass.services.async_call(
light.DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True
await hass.async_block_till_done() )
assert not light.is_on(hass, ent1.entity_id) assert not light.is_on(hass, ent1.entity_id)
assert not light.is_on(hass, ent2.entity_id) assert not light.is_on(hass, ent2.entity_id)
assert not light.is_on(hass, ent3.entity_id) assert not light.is_on(hass, ent3.entity_id)
# Ensure all attributes process correctly # Ensure all attributes process correctly
await common.async_turn_on( await hass.services.async_call(
hass, ent1.entity_id, transition=10, brightness=20, color_name="blue" light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent1.entity_id,
light.ATTR_TRANSITION: 10,
light.ATTR_BRIGHTNESS: 20,
light.ATTR_COLOR_NAME: "blue",
},
blocking=True,
) )
await common.async_turn_on( await hass.services.async_call(
hass, ent2.entity_id, rgb_color=(255, 255, 255), white_value=255 light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent2.entity_id,
light.ATTR_RGB_COLOR: (255, 255, 255),
light.ATTR_WHITE_VALUE: 255,
},
blocking=True,
)
await hass.services.async_call(
light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent3.entity_id,
light.ATTR_XY_COLOR: (0.4, 0.6),
},
blocking=True,
) )
await common.async_turn_on(hass, ent3.entity_id, xy_color=(0.4, 0.6))
await hass.async_block_till_done()
_, data = ent1.last_call("turn_on") _, data = ent1.last_call("turn_on")
assert { assert data == {
light.ATTR_TRANSITION: 10, light.ATTR_TRANSITION: 10,
light.ATTR_BRIGHTNESS: 20, light.ATTR_BRIGHTNESS: 20,
light.ATTR_HS_COLOR: (240, 100), light.ATTR_HS_COLOR: (240, 100),
} == data }
_, data = ent2.last_call("turn_on") _, data = ent2.last_call("turn_on")
assert {light.ATTR_HS_COLOR: (0, 0), light.ATTR_WHITE_VALUE: 255} == data assert data == {light.ATTR_HS_COLOR: (0, 0), light.ATTR_WHITE_VALUE: 255}
_, data = ent3.last_call("turn_on") _, data = ent3.last_call("turn_on")
assert {light.ATTR_HS_COLOR: (71.059, 100)} == data assert data == {light.ATTR_HS_COLOR: (71.059, 100)}
# Ensure attributes are filtered when light is turned off # Ensure attributes are filtered when light is turned off
await common.async_turn_on( await hass.services.async_call(
hass, ent1.entity_id, transition=10, brightness=0, color_name="blue" light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent1.entity_id,
light.ATTR_TRANSITION: 10,
light.ATTR_BRIGHTNESS: 0,
light.ATTR_COLOR_NAME: "blue",
},
blocking=True,
) )
await common.async_turn_on( await hass.services.async_call(
hass, light.DOMAIN,
ent2.entity_id, SERVICE_TURN_ON,
brightness=0, {
rgb_color=(255, 255, 255), ATTR_ENTITY_ID: ent2.entity_id,
white_value=0, light.ATTR_BRIGHTNESS: 0,
light.ATTR_RGB_COLOR: (255, 255, 255),
light.ATTR_WHITE_VALUE: 0,
},
blocking=True,
)
await hass.services.async_call(
light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent3.entity_id,
light.ATTR_BRIGHTNESS: 0,
light.ATTR_XY_COLOR: (0.4, 0.6),
},
blocking=True,
) )
await common.async_turn_on(hass, ent3.entity_id, brightness=0, xy_color=(0.4, 0.6))
await hass.async_block_till_done()
assert not light.is_on(hass, ent1.entity_id) assert not light.is_on(hass, ent1.entity_id)
assert not light.is_on(hass, ent2.entity_id) assert not light.is_on(hass, ent2.entity_id)
assert not light.is_on(hass, ent3.entity_id) assert not light.is_on(hass, ent3.entity_id)
_, data = ent1.last_call("turn_off") _, data = ent1.last_call("turn_off")
assert {light.ATTR_TRANSITION: 10} == data assert data == {light.ATTR_TRANSITION: 10}
_, data = ent2.last_call("turn_off") _, data = ent2.last_call("turn_off")
assert {} == data assert data == {}
_, data = ent3.last_call("turn_off") _, data = ent3.last_call("turn_off")
assert {} == data assert data == {}
# One of the light profiles # One of the light profiles
prof_name, prof_h, prof_s, prof_bri, prof_t = "relax", 35.932, 69.412, 144, 0 prof_name, prof_h, prof_s, prof_bri, prof_t = "relax", 35.932, 69.412, 144, 0
# Test light profiles # Test light profiles
await common.async_turn_on(hass, ent1.entity_id, profile=prof_name) await hass.services.async_call(
light.DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent1.entity_id, light.ATTR_PROFILE: prof_name},
blocking=True,
)
# Specify a profile and a brightness attribute to overwrite it # Specify a profile and a brightness attribute to overwrite it
await common.async_turn_on( await hass.services.async_call(
hass, ent2.entity_id, profile=prof_name, brightness=100, transition=1 light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent2.entity_id,
light.ATTR_PROFILE: prof_name,
light.ATTR_BRIGHTNESS: 100,
light.ATTR_TRANSITION: 1,
},
blocking=True,
) )
await hass.async_block_till_done()
_, data = ent1.last_call("turn_on") _, data = ent1.last_call("turn_on")
assert { assert data == {
light.ATTR_BRIGHTNESS: prof_bri, light.ATTR_BRIGHTNESS: prof_bri,
light.ATTR_HS_COLOR: (prof_h, prof_s), light.ATTR_HS_COLOR: (prof_h, prof_s),
light.ATTR_TRANSITION: prof_t, light.ATTR_TRANSITION: prof_t,
} == data }
_, data = ent2.last_call("turn_on") _, data = ent2.last_call("turn_on")
assert { assert data == {
light.ATTR_BRIGHTNESS: 100, light.ATTR_BRIGHTNESS: 100,
light.ATTR_HS_COLOR: (prof_h, prof_s), light.ATTR_HS_COLOR: (prof_h, prof_s),
light.ATTR_TRANSITION: 1, light.ATTR_TRANSITION: 1,
} == data }
# Test toggle with parameters # Test toggle with parameters
await common.async_toggle( await hass.services.async_call(
hass, ent3.entity_id, profile=prof_name, brightness_pct=100 light.DOMAIN,
SERVICE_TOGGLE,
{
ATTR_ENTITY_ID: ent3.entity_id,
light.ATTR_PROFILE: prof_name,
light.ATTR_BRIGHTNESS_PCT: 100,
},
blocking=True,
) )
await hass.async_block_till_done()
_, data = ent3.last_call("turn_on") _, data = ent3.last_call("turn_on")
assert { assert data == {
light.ATTR_BRIGHTNESS: 255, light.ATTR_BRIGHTNESS: 255,
light.ATTR_HS_COLOR: (prof_h, prof_s), light.ATTR_HS_COLOR: (prof_h, prof_s),
light.ATTR_TRANSITION: prof_t, light.ATTR_TRANSITION: prof_t,
} == data }
# Test bad data # Test bad data
await common.async_turn_on(hass) await hass.services.async_call(
await common.async_turn_on(hass, ent1.entity_id, profile="nonexisting") light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True
)
await hass.services.async_call(
light.DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent1.entity_id, light.ATTR_PROFILE: -1},
blocking=True,
)
with pytest.raises(vol.MultipleInvalid): with pytest.raises(vol.MultipleInvalid):
await common.async_turn_on(hass, ent2.entity_id, xy_color=["bla-di-bla", 5]) await hass.services.async_call(
light.DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent2.entity_id, light.ATTR_XY_COLOR: ["bla-di-bla", 5]},
blocking=True,
)
with pytest.raises(vol.MultipleInvalid): with pytest.raises(vol.MultipleInvalid):
await common.async_turn_on(hass, ent3.entity_id, rgb_color=[255, None, 2]) await hass.services.async_call(
light.DOMAIN,
await hass.async_block_till_done() SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent3.entity_id, light.ATTR_RGB_COLOR: [255, None, 2]},
blocking=True,
)
_, data = ent1.last_call("turn_on") _, data = ent1.last_call("turn_on")
assert {} == data assert data == {}
_, data = ent2.last_call("turn_on") _, data = ent2.last_call("turn_on")
assert {} == data assert data == {}
_, data = ent3.last_call("turn_on") _, data = ent3.last_call("turn_on")
assert {} == data assert data == {}
# faulty attributes will not trigger a service call # faulty attributes will not trigger a service call
with pytest.raises(vol.MultipleInvalid): with pytest.raises(vol.MultipleInvalid):
await common.async_turn_on( await hass.services.async_call(
hass, ent1.entity_id, profile=prof_name, brightness="bright" light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent1.entity_id,
light.ATTR_PROFILE: prof_name,
light.ATTR_BRIGHTNESS: "bright",
},
blocking=True,
) )
with pytest.raises(vol.MultipleInvalid): with pytest.raises(vol.MultipleInvalid):
await common.async_turn_on(hass, ent1.entity_id, rgb_color="yellowish") await hass.services.async_call(
light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent1.entity_id,
light.ATTR_RGB_COLOR: "yellowish",
},
blocking=True,
)
with pytest.raises(vol.MultipleInvalid): with pytest.raises(vol.MultipleInvalid):
await common.async_turn_on(hass, ent2.entity_id, white_value="high") await hass.services.async_call(
light.DOMAIN,
await hass.async_block_till_done() SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent2.entity_id, light.ATTR_WHITE_VALUE: "high"},
blocking=True,
)
_, data = ent1.last_call("turn_on") _, data = ent1.last_call("turn_on")
assert {} == data assert data == {}
_, data = ent2.last_call("turn_on") _, data = ent2.last_call("turn_on")
assert {} == data assert data == {}
async def test_broken_light_profiles(hass, mock_storage): async def test_broken_light_profiles(hass, mock_storage):
@ -346,12 +454,17 @@ async def test_light_profiles(hass, mock_storage):
ent1, _, _ = platform.ENTITIES ent1, _, _ = platform.ENTITIES
await common.async_turn_on(hass, ent1.entity_id, profile="test") await hass.services.async_call(
light.DOMAIN,
await hass.async_block_till_done() SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: ent1.entity_id,
light.ATTR_PROFILE: "test",
},
blocking=True,
)
_, data = ent1.last_call("turn_on") _, data = ent1.last_call("turn_on")
assert light.is_on(hass, ent1.entity_id) assert light.is_on(hass, ent1.entity_id)
assert data == { assert data == {
light.ATTR_HS_COLOR: (71.059, 100), light.ATTR_HS_COLOR: (71.059, 100),
@ -359,12 +472,14 @@ async def test_light_profiles(hass, mock_storage):
light.ATTR_TRANSITION: 0, light.ATTR_TRANSITION: 0,
} }
await common.async_turn_on(hass, ent1.entity_id, profile="test_off") await hass.services.async_call(
light.DOMAIN,
await hass.async_block_till_done() SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent1.entity_id, light.ATTR_PROFILE: "test_off"},
blocking=True,
)
_, data = ent1.last_call("turn_off") _, data = ent1.last_call("turn_off")
assert not light.is_on(hass, ent1.entity_id) assert not light.is_on(hass, ent1.entity_id)
assert data == {light.ATTR_TRANSITION: 0} assert data == {light.ATTR_TRANSITION: 0}
@ -388,12 +503,14 @@ async def test_light_profiles_with_transition(hass, mock_storage):
ent1, _, _ = platform.ENTITIES ent1, _, _ = platform.ENTITIES
await common.async_turn_on(hass, ent1.entity_id, profile="test") await hass.services.async_call(
light.DOMAIN,
await hass.async_block_till_done() SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent1.entity_id, light.ATTR_PROFILE: "test"},
blocking=True,
)
_, data = ent1.last_call("turn_on") _, data = ent1.last_call("turn_on")
assert light.is_on(hass, ent1.entity_id) assert light.is_on(hass, ent1.entity_id)
assert data == { assert data == {
light.ATTR_HS_COLOR: (71.059, 100), light.ATTR_HS_COLOR: (71.059, 100),
@ -401,12 +518,14 @@ async def test_light_profiles_with_transition(hass, mock_storage):
light.ATTR_TRANSITION: 2, light.ATTR_TRANSITION: 2,
} }
await common.async_turn_on(hass, ent1.entity_id, profile="test_off") await hass.services.async_call(
light.DOMAIN,
await hass.async_block_till_done() SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent1.entity_id, light.ATTR_PROFILE: "test_off"},
blocking=True,
)
_, data = ent1.last_call("turn_off") _, data = ent1.last_call("turn_off")
assert not light.is_on(hass, ent1.entity_id) assert not light.is_on(hass, ent1.entity_id)
assert data == {light.ATTR_TRANSITION: 0} assert data == {light.ATTR_TRANSITION: 0}
@ -440,8 +559,10 @@ async def test_default_profiles_group(hass, mock_storage):
await hass.async_block_till_done() await hass.async_block_till_done()
ent, _, _ = platform.ENTITIES ent, _, _ = platform.ENTITIES
await common.async_turn_on(hass, ent.entity_id) await hass.services.async_call(
await hass.async_block_till_done() light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ent.entity_id}, blocking=True
)
_, data = ent.last_call("turn_on") _, data = ent.last_call("turn_on")
assert data == { assert data == {
light.ATTR_HS_COLOR: (71.059, 100), light.ATTR_HS_COLOR: (71.059, 100),
@ -483,8 +604,15 @@ async def test_default_profiles_light(hass, mock_storage):
await hass.async_block_till_done() await hass.async_block_till_done()
dev = next(filter(lambda x: x.entity_id == "light.ceiling_2", platform.ENTITIES)) dev = next(filter(lambda x: x.entity_id == "light.ceiling_2", platform.ENTITIES))
await common.async_turn_on(hass, dev.entity_id) await hass.services.async_call(
await hass.async_block_till_done() light.DOMAIN,
SERVICE_TURN_ON,
{
ATTR_ENTITY_ID: dev.entity_id,
},
blocking=True,
)
_, data = dev.last_call("turn_on") _, data = dev.last_call("turn_on")
assert data == { assert data == {
light.ATTR_HS_COLOR: (50.353, 100), light.ATTR_HS_COLOR: (50.353, 100),
@ -507,8 +635,8 @@ async def test_light_context(hass, hass_admin_user):
"light", "light",
"toggle", "toggle",
{"entity_id": state.entity_id}, {"entity_id": state.entity_id},
True, blocking=True,
core.Context(user_id=hass_admin_user.id), context=core.Context(user_id=hass_admin_user.id),
) )
state2 = hass.states.get("light.ceiling") state2 = hass.states.get("light.ceiling")
@ -534,8 +662,8 @@ async def test_light_turn_on_auth(hass, hass_admin_user):
"light", "light",
"turn_on", "turn_on",
{"entity_id": state.entity_id}, {"entity_id": state.entity_id},
True, blocking=True,
core.Context(user_id=hass_admin_user.id), context=core.Context(user_id=hass_admin_user.id),
) )
@ -557,7 +685,7 @@ async def test_light_brightness_step(hass):
"light", "light",
"turn_on", "turn_on",
{"entity_id": entity.entity_id, "brightness_step": -10}, {"entity_id": entity.entity_id, "brightness_step": -10},
True, blocking=True,
) )
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")
@ -567,7 +695,7 @@ async def test_light_brightness_step(hass):
"light", "light",
"turn_on", "turn_on",
{"entity_id": entity.entity_id, "brightness_step_pct": 10}, {"entity_id": entity.entity_id, "brightness_step_pct": 10},
True, blocking=True,
) )
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")
@ -592,7 +720,7 @@ async def test_light_brightness_pct_conversion(hass):
"light", "light",
"turn_on", "turn_on",
{"entity_id": entity.entity_id, "brightness_pct": 1}, {"entity_id": entity.entity_id, "brightness_pct": 1},
True, blocking=True,
) )
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")
@ -602,7 +730,7 @@ async def test_light_brightness_pct_conversion(hass):
"light", "light",
"turn_on", "turn_on",
{"entity_id": entity.entity_id, "brightness_pct": 2}, {"entity_id": entity.entity_id, "brightness_pct": 2},
True, blocking=True,
) )
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")
@ -612,7 +740,7 @@ async def test_light_brightness_pct_conversion(hass):
"light", "light",
"turn_on", "turn_on",
{"entity_id": entity.entity_id, "brightness_pct": 50}, {"entity_id": entity.entity_id, "brightness_pct": 50},
True, blocking=True,
) )
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")
@ -622,7 +750,7 @@ async def test_light_brightness_pct_conversion(hass):
"light", "light",
"turn_on", "turn_on",
{"entity_id": entity.entity_id, "brightness_pct": 99}, {"entity_id": entity.entity_id, "brightness_pct": 99},
True, blocking=True,
) )
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")
@ -632,7 +760,7 @@ async def test_light_brightness_pct_conversion(hass):
"light", "light",
"turn_on", "turn_on",
{"entity_id": entity.entity_id, "brightness_pct": 100}, {"entity_id": entity.entity_id, "brightness_pct": 100},
True, blocking=True,
) )
_, data = entity.last_call("turn_on") _, data = entity.last_call("turn_on")