mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Merge pull request #388 from stefan-jonasson/dev
[Bugfix] - Time trigger fired all the time when using the "from" param
This commit is contained in:
commit
3ed102cd88
@ -19,20 +19,27 @@ CONF_WEEKDAY = "weekday"
|
|||||||
|
|
||||||
WEEKDAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
|
WEEKDAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def trigger(hass, config, action):
|
def trigger(hass, config, action):
|
||||||
""" Listen for state changes based on `config`. """
|
""" Listen for state changes based on `config`. """
|
||||||
if CONF_AFTER in config:
|
if CONF_AFTER in config:
|
||||||
after = dt_util.parse_time_str(config[CONF_AFTER])
|
after = dt_util.parse_time_str(config[CONF_AFTER])
|
||||||
if after is None:
|
if after is None:
|
||||||
logging.getLogger(__name__).error(
|
_LOGGER.error(
|
||||||
'Received invalid after value: %s', config[CONF_AFTER])
|
'Received invalid after value: %s', config[CONF_AFTER])
|
||||||
return False
|
return False
|
||||||
hours, minutes, seconds = after.hour, after.minute, after.second
|
hours, minutes, seconds = after.hour, after.minute, after.second
|
||||||
|
elif (CONF_HOURS in config or CONF_MINUTES in config
|
||||||
hours = convert(config.get(CONF_HOURS), int)
|
or CONF_SECONDS in config):
|
||||||
minutes = convert(config.get(CONF_MINUTES), int)
|
hours = convert(config.get(CONF_HOURS), int)
|
||||||
seconds = convert(config.get(CONF_SECONDS), int)
|
minutes = convert(config.get(CONF_MINUTES), int)
|
||||||
|
seconds = convert(config.get(CONF_SECONDS), int)
|
||||||
|
else:
|
||||||
|
_LOGGER.error('One of %s, %s, %s OR %s needs to be specified',
|
||||||
|
CONF_HOURS, CONF_MINUTES, CONF_SECONDS, CONF_AFTER)
|
||||||
|
return False
|
||||||
|
|
||||||
def time_automation_listener(now):
|
def time_automation_listener(now):
|
||||||
""" Listens for time changes and calls action. """
|
""" Listens for time changes and calls action. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user