Add brightness_step to light.turn_on (#31452)
* Clean up light turn on service * Add brightness_step to turn_on schema * Fix import * Fix imports 2 * Fix RFLink test
This commit is contained in:
1 parent
e970177eeb
commit
c85a7934ed
7 files changed
+115
-73
No files matched your search
@@ -462,3 +462,37 @@ async def test_light_turn_on_auth(hass, hass_admin_user):
|
||||
True,
|
||||
core.Context(user_id=hass_admin_user.id),
|
||||
)
|
||||
|
||||
|
||||
async def test_light_brightness_step(hass):
|
||||
"""Test that light context works."""
|
||||
platform = getattr(hass.components, "test.light")
|
||||
platform.init()
|
||||
entity = platform.ENTITIES[0]
|
||||
entity.supported_features = light.SUPPORT_BRIGHTNESS
|
||||
entity.brightness = 100
|
||||
assert await async_setup_component(hass, "light", {"light": {"platform": "test"}})
|
||||
|
||||
state = hass.states.get(entity.entity_id)
|
||||
assert state is not None
|
||||
assert state.attributes["brightness"] == 100
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_on",
|
||||
{"entity_id": entity.entity_id, "brightness_step": -10},
|
||||
True,
|
||||
)
|
||||
|
||||
_, data = entity.last_call("turn_on")
|
||||
assert data["brightness"] == 90, data
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_on",
|
||||
{"entity_id": entity.entity_id, "brightness_step_pct": 10},
|
||||
True,
|
||||
)
|
||||
|
||||
_, data = entity.last_call("turn_on")
|
||||
assert data["brightness"] == 125, data
|
||||
@@ -298,18 +298,16 @@ async def test_signal_repetitions_cancelling(hass, monkeypatch):
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
)
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DOMAIN + ".test"}, blocking=True
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert protocol.send_command_ack.call_args_list[0][0][1] == "off"
|
||||
assert protocol.send_command_ack.call_args_list[1][0][1] == "on"
|
||||
assert protocol.send_command_ack.call_args_list[2][0][1] == "on"
|
||||
assert protocol.send_command_ack.call_args_list[3][0][1] == "on"
|
||||
assert [call[0][1] for call in protocol.send_command_ack.call_args_list] == [
|
||||
"off",
|
||||
"on",
|
||||
"on",
|
||||
"on",
|
||||
]
|
||||
|
||||
|
||||
async def test_type_toggle(hass, monkeypatch):
|
||||
|
||||
Reference in new issue
Block a user