Component Automation - initial version

This commit is contained in:
Paulus Schoutsen 2015-01-15 23:32:27 -08:00
parent db48b2ba34
commit 9ffe35756b
5 changed files with 164 additions and 4 deletions

View file

@ -0,0 +1,29 @@
"""
homeassistant.components.automation.time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers time listening automation rules.
"""
from homeassistant.util import convert
CONF_HOURS = "time_hours"
CONF_MINUTES = "time_minutes"
CONF_SECONDS = "time_seconds"
def register(hass, config, action):
""" Listen for state changes based on `config`. """
hours = convert(config.get(CONF_HOURS), int)
minutes = convert(config.get(CONF_MINUTES), int)
seconds = convert(config.get(CONF_SECONDS), int)
# pylint: disable=unused-argument
def time_automation_listener(now):
""" Listens for time changes and calls action. """
action()
hass.track_time_change(
time_automation_listener,
hour=hours, minute=minutes, second=seconds)
return True