Remove service helper (4) (#16892)

* Update media_player

* Update lock

* Update notify

* Update remote

* Update scene

* Update vacuum

* Remove timer helpers

* Removed unused legacy helpers
This commit is contained in:
cdce8p authored and Paulus Schoutsen committed 2018-09-26 18:02:05 +02:00
1 parent d0ddc28f96
commit dd45e99302
23 files changed
+499 -520

No files matched your search

@@ -12,12 +12,10 @@ import voluptuous as vol
import homeassistant.util.dt as dt_util
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (ATTR_ENTITY_ID, CONF_ICON, CONF_NAME)
from homeassistant.core import callback
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.loader import bind_hass
_LOGGER = logging.getLogger(__name__)
@@ -63,64 +61,6 @@ CONFIG_SCHEMA = vol.Schema({
}, extra=vol.ALLOW_EXTRA)
@bind_hass
def start(hass, entity_id, duration):
"""Start a timer."""
hass.add_job(async_start, hass, entity_id, {ATTR_ENTITY_ID: entity_id,
ATTR_DURATION: duration})
@callback
@bind_hass
def async_start(hass, entity_id, duration):
"""Start a timer."""
hass.async_add_job(hass.services.async_call(
DOMAIN, SERVICE_START, {ATTR_ENTITY_ID: entity_id,
ATTR_DURATION: duration}))
@bind_hass
def pause(hass, entity_id):
"""Pause a timer."""
hass.add_job(async_pause, hass, entity_id)
@callback
@bind_hass
def async_pause(hass, entity_id):
"""Pause a timer."""
hass.async_add_job(hass.services.async_call(
DOMAIN, SERVICE_PAUSE, {ATTR_ENTITY_ID: entity_id}))
@bind_hass
def cancel(hass, entity_id):
"""Cancel a timer."""
hass.add_job(async_cancel, hass, entity_id)
@callback
@bind_hass
def async_cancel(hass, entity_id):
"""Cancel a timer."""
hass.async_add_job(hass.services.async_call(
DOMAIN, SERVICE_CANCEL, {ATTR_ENTITY_ID: entity_id}))
@bind_hass
def finish(hass, entity_id):
"""Finish a timer."""
hass.add_job(async_cancel, hass, entity_id)
@callback
@bind_hass
def async_finish(hass, entity_id):
"""Finish a timer."""
hass.async_add_job(hass.services.async_call(
DOMAIN, SERVICE_FINISH, {ATTR_ENTITY_ID: entity_id}))
async def async_setup(hass, config):
"""Set up a timer."""
component = EntityComponent(_LOGGER, DOMAIN, hass)