diff --git a/homeassistant/components/automation/time.py b/homeassistant/components/automation/time.py index 3d590ea8cfa..4ef55820e61 100644 --- a/homeassistant/components/automation/time.py +++ b/homeassistant/components/automation/time.py @@ -71,7 +71,7 @@ def if_action(hass, config): weekday = config.get(CONF_WEEKDAY) if before is None and after is None and weekday is None: - logging.getLogger(__name__).error( + _LOGGER.error( "Missing if-condition configuration key %s, %s or %s", CONF_BEFORE, CONF_AFTER, CONF_WEEKDAY) return None diff --git a/tests/components/automation/test_time.py b/tests/components/automation/test_time.py index e233c93988d..991ca8dbc5a 100644 --- a/tests/components/automation/test_time.py +++ b/tests/components/automation/test_time.py @@ -301,6 +301,63 @@ class TestAutomationTime(unittest.TestCase): self.hass.pool.block_till_done() self.assertEqual(1, len(self.calls)) + def test_if_fires_periodic_seconds(self): + self.assertTrue(automation.setup(self.hass, { + automation.DOMAIN: { + 'trigger': { + 'platform': 'time', + 'seconds': "/2", + }, + 'action': { + 'service': 'test.automation' + } + } + })) + + fire_time_changed(self.hass, dt_util.utcnow().replace( + hour=0, minute=0, second=2)) + + self.hass.pool.block_till_done() + self.assertEqual(1, len(self.calls)) + + def test_if_fires_periodic_minutes(self): + self.assertTrue(automation.setup(self.hass, { + automation.DOMAIN: { + 'trigger': { + 'platform': 'time', + 'minutes': "/2", + }, + 'action': { + 'service': 'test.automation' + } + } + })) + + fire_time_changed(self.hass, dt_util.utcnow().replace( + hour=0, minute=2, second=0)) + + self.hass.pool.block_till_done() + self.assertEqual(1, len(self.calls)) + + def test_if_fires_periodic_hours(self): + self.assertTrue(automation.setup(self.hass, { + automation.DOMAIN: { + 'trigger': { + 'platform': 'time', + 'hours': "/2", + }, + 'action': { + 'service': 'test.automation' + } + } + })) + + fire_time_changed(self.hass, dt_util.utcnow().replace( + hour=2, minute=0, second=0)) + + self.hass.pool.block_till_done() + self.assertEqual(1, len(self.calls)) + def test_if_fires_using_after(self): self.assertTrue(automation.setup(self.hass, { automation.DOMAIN: {