This commit is contained in:
Paulus Schoutsen 2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View file

@ -4,12 +4,26 @@ All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
from homeassistant.components.vacuum import (
ATTR_FAN_SPEED, ATTR_PARAMS, DOMAIN, SERVICE_CLEAN_SPOT, SERVICE_LOCATE,
SERVICE_PAUSE, SERVICE_SEND_COMMAND, SERVICE_SET_FAN_SPEED, SERVICE_START,
SERVICE_START_PAUSE, SERVICE_STOP, SERVICE_RETURN_TO_BASE)
ATTR_FAN_SPEED,
ATTR_PARAMS,
DOMAIN,
SERVICE_CLEAN_SPOT,
SERVICE_LOCATE,
SERVICE_PAUSE,
SERVICE_SEND_COMMAND,
SERVICE_SET_FAN_SPEED,
SERVICE_START,
SERVICE_START_PAUSE,
SERVICE_STOP,
SERVICE_RETURN_TO_BASE,
)
from homeassistant.const import (
ATTR_COMMAND, ATTR_ENTITY_ID, SERVICE_TOGGLE,
SERVICE_TURN_OFF, SERVICE_TURN_ON)
ATTR_COMMAND,
ATTR_ENTITY_ID,
SERVICE_TOGGLE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
)
from homeassistant.loader import bind_hass
@ -22,8 +36,7 @@ def turn_on(hass, entity_id=None):
async def async_turn_on(hass, entity_id=None):
"""Turn all or specified vacuum on."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_TURN_ON, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data, blocking=True)
@bind_hass
@ -35,8 +48,7 @@ def turn_off(hass, entity_id=None):
async def async_turn_off(hass, entity_id=None):
"""Turn all or specified vacuum off."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_TURN_OFF, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_TURN_OFF, data, blocking=True)
@bind_hass
@ -48,8 +60,7 @@ def toggle(hass, entity_id=None):
async def async_toggle(hass, entity_id=None):
"""Toggle all or specified vacuum."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_TOGGLE, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_TOGGLE, data, blocking=True)
@bind_hass
@ -61,8 +72,7 @@ def locate(hass, entity_id=None):
async def async_locate(hass, entity_id=None):
"""Locate all or specified vacuum."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_LOCATE, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_LOCATE, data, blocking=True)
@bind_hass
@ -74,8 +84,7 @@ def clean_spot(hass, entity_id=None):
async def async_clean_spot(hass, entity_id=None):
"""Tell all or specified vacuum to perform a spot clean-up."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_CLEAN_SPOT, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_CLEAN_SPOT, data, blocking=True)
@bind_hass
@ -87,8 +96,7 @@ def return_to_base(hass, entity_id=None):
async def async_return_to_base(hass, entity_id=None):
"""Tell all or specified vacuum to return to base."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_RETURN_TO_BASE, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_RETURN_TO_BASE, data, blocking=True)
@bind_hass
@ -100,8 +108,7 @@ def start_pause(hass, entity_id=None):
async def async_start_pause(hass, entity_id=None):
"""Tell all or specified vacuum to start or pause the current task."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_START_PAUSE, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_START_PAUSE, data, blocking=True)
@bind_hass
@ -113,8 +120,7 @@ def start(hass, entity_id=None):
async def async_start(hass, entity_id=None):
"""Tell all or specified vacuum to start or resume the current task."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_START, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_START, data, blocking=True)
@bind_hass
@ -126,8 +132,7 @@ def pause(hass, entity_id=None):
async def async_pause(hass, entity_id=None):
"""Tell all or the specified vacuum to pause the current task."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_PAUSE, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_PAUSE, data, blocking=True)
@bind_hass
@ -139,8 +144,7 @@ def stop(hass, entity_id=None):
async def async_stop(hass, entity_id=None):
"""Stop all or specified vacuum."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
await hass.services.async_call(
DOMAIN, SERVICE_STOP, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_STOP, data, blocking=True)
@bind_hass
@ -153,8 +157,7 @@ async def async_set_fan_speed(hass, fan_speed, entity_id=None):
"""Set fan speed for all or specified vacuum."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
data[ATTR_FAN_SPEED] = fan_speed
await hass.services.async_call(
DOMAIN, SERVICE_SET_FAN_SPEED, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_SET_FAN_SPEED, data, blocking=True)
@bind_hass
@ -169,5 +172,4 @@ async def async_send_command(hass, command, params=None, entity_id=None):
data[ATTR_COMMAND] = command
if params is not None:
data[ATTR_PARAMS] = params
await hass.services.async_call(
DOMAIN, SERVICE_SEND_COMMAND, data, blocking=True)
await hass.services.async_call(DOMAIN, SERVICE_SEND_COMMAND, data, blocking=True)