mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Convert some test helpers to coroutines and adjust tests (#23352)
* Convert some test helpers to coroutines * Fix tests
This commit is contained in:
committed by
Martin Hjelmare
parent
86b017e2f0
commit
5376e15286
@@ -6,7 +6,6 @@ components. Instead call the service directly.
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
|
||||
@@ -16,12 +15,11 @@ def turn_on(hass, entity_id=None):
|
||||
hass.add_job(async_turn_on, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_turn_on(hass, entity_id=None):
|
||||
async def async_turn_on(hass, entity_id=None):
|
||||
"""Turn all or specified switch on."""
|
||||
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
|
||||
hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, data, blocking=True)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -30,10 +28,8 @@ def turn_off(hass, entity_id=None):
|
||||
hass.add_job(async_turn_off, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_turn_off(hass, entity_id=None):
|
||||
async def async_turn_off(hass, entity_id=None):
|
||||
"""Turn all or specified switch off."""
|
||||
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
|
||||
hass.async_add_job(
|
||||
hass.services.async_call(DOMAIN, SERVICE_TURN_OFF, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, data, blocking=True)
|
||||
|
||||
Reference in New Issue
Block a user