Add scene.apply service (#27298)

* Add scene.apply service

* Use return value entity ID validator"

* Require entities field in service call

* Simplify scene service
This commit is contained in:
Paulus Schoutsen 2019-10-08 09:59:32 -07:00 committed by GitHub
parent a51e0d7a5f
commit f5bd0f29b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 93 additions and 54 deletions

View file

@ -28,3 +28,26 @@ async def test_reload_config_service(hass):
assert hass.states.get("scene.hallo") is None
assert hass.states.get("scene.bye") is not None
async def test_apply_service(hass):
"""Test the apply service."""
assert await async_setup_component(hass, "scene", {})
assert await async_setup_component(hass, "light", {"light": {"platform": "demo"}})
assert await hass.services.async_call(
"scene", "apply", {"entities": {"light.bed_light": "off"}}, blocking=True
)
assert hass.states.get("light.bed_light").state == "off"
assert await hass.services.async_call(
"scene",
"apply",
{"entities": {"light.bed_light": {"state": "on", "brightness": 50}}},
blocking=True,
)
state = hass.states.get("light.bed_light")
assert state.state == "on"
assert state.attributes["brightness"] == 50