mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +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
@@ -9,12 +9,9 @@ from homeassistant.const import (
|
||||
SERVICE_ALARM_DISARM, SERVICE_ALARM_ARM_HOME, SERVICE_ALARM_ARM_AWAY,
|
||||
SERVICE_ALARM_ARM_NIGHT, SERVICE_ALARM_ARM_CUSTOM_BYPASS)
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.core import callback
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_alarm_disarm(hass, code=None, entity_id=None):
|
||||
async def async_alarm_disarm(hass, code=None, entity_id=None):
|
||||
"""Send the alarm the command for disarm."""
|
||||
data = {}
|
||||
if code:
|
||||
@@ -22,8 +19,8 @@ def async_alarm_disarm(hass, code=None, entity_id=None):
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(DOMAIN, SERVICE_ALARM_DISARM, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_ALARM_DISARM, data, blocking=True)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -38,9 +35,7 @@ def alarm_disarm(hass, code=None, entity_id=None):
|
||||
hass.services.call(DOMAIN, SERVICE_ALARM_DISARM, data)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_alarm_arm_home(hass, code=None, entity_id=None):
|
||||
async def async_alarm_arm_home(hass, code=None, entity_id=None):
|
||||
"""Send the alarm the command for disarm."""
|
||||
data = {}
|
||||
if code:
|
||||
@@ -48,8 +43,8 @@ def async_alarm_arm_home(hass, code=None, entity_id=None):
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(DOMAIN, SERVICE_ALARM_ARM_HOME, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_ALARM_ARM_HOME, data, blocking=True)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -64,9 +59,7 @@ def alarm_arm_home(hass, code=None, entity_id=None):
|
||||
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_HOME, data)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_alarm_arm_away(hass, code=None, entity_id=None):
|
||||
async def async_alarm_arm_away(hass, code=None, entity_id=None):
|
||||
"""Send the alarm the command for disarm."""
|
||||
data = {}
|
||||
if code:
|
||||
@@ -74,8 +67,8 @@ def async_alarm_arm_away(hass, code=None, entity_id=None):
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_ALARM_ARM_AWAY, data, blocking=True)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -90,9 +83,7 @@ def alarm_arm_away(hass, code=None, entity_id=None):
|
||||
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_alarm_arm_night(hass, code=None, entity_id=None):
|
||||
async def async_alarm_arm_night(hass, code=None, entity_id=None):
|
||||
"""Send the alarm the command for disarm."""
|
||||
data = {}
|
||||
if code:
|
||||
@@ -100,8 +91,8 @@ def async_alarm_arm_night(hass, code=None, entity_id=None):
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(DOMAIN, SERVICE_ALARM_ARM_NIGHT, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_ALARM_ARM_NIGHT, data, blocking=True)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -116,9 +107,7 @@ def alarm_arm_night(hass, code=None, entity_id=None):
|
||||
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_NIGHT, data)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_alarm_trigger(hass, code=None, entity_id=None):
|
||||
async def async_alarm_trigger(hass, code=None, entity_id=None):
|
||||
"""Send the alarm the command for disarm."""
|
||||
data = {}
|
||||
if code:
|
||||
@@ -126,8 +115,8 @@ def async_alarm_trigger(hass, code=None, entity_id=None):
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(DOMAIN, SERVICE_ALARM_TRIGGER, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_ALARM_TRIGGER, data, blocking=True)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -142,9 +131,7 @@ def alarm_trigger(hass, code=None, entity_id=None):
|
||||
hass.services.call(DOMAIN, SERVICE_ALARM_TRIGGER, data)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_alarm_arm_custom_bypass(hass, code=None, entity_id=None):
|
||||
async def async_alarm_arm_custom_bypass(hass, code=None, entity_id=None):
|
||||
"""Send the alarm the command for disarm."""
|
||||
data = {}
|
||||
if code:
|
||||
@@ -152,9 +139,8 @@ def async_alarm_arm_custom_bypass(hass, code=None, entity_id=None):
|
||||
if entity_id:
|
||||
data[ATTR_ENTITY_ID] = entity_id
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_ALARM_ARM_CUSTOM_BYPASS, data))
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_ALARM_ARM_CUSTOM_BYPASS, data, blocking=True)
|
||||
|
||||
|
||||
@bind_hass
|
||||
|
||||
Reference in New Issue
Block a user