Python homeassistant.helpers.config_validation.slug() Examples
The following are 2
code examples of homeassistant.helpers.config_validation.slug().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
homeassistant.helpers.config_validation
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: __init__.py From home-assistant-custom-components with MIT License | 6 votes |
def __init__(self, hass, slug, name, hour, minute, day, month, year, message, days_notice, notifier, recurrence, countdown): self.hass = hass self.entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, slug, hass=hass) self._name = name self._hour = hour self._minute = minute self._day = day self._month = month self._message = message self._days_notice = days_notice self._notifier = notifier self._year = year self._recurrence = recurrence self._countdown = countdown self._dates_list = [] if self._recurrence != ATTR_PAST_DUE: if self._countdown and self._days_notice > 0: for i in range(0, self._days_notice + 1): self._dates_list.append(self.create_due_date(i)) else: self._dates_list.append(self.create_due_date(self._days_notice))
Example #2
Source File: __init__.py From home-assistant-custom-components with MIT License | 4 votes |
def async_setup(hass, config): component = EntityComponent(_LOGGER, DOMAIN, hass) entities = [] for slug, config in config[DOMAIN].items(): if not config: config = {} name = config.get(NAME) hour = config.get(HOUR) minute = config.get(MINUTE) day = None month = None year = None message = config.get(MESSAGE) days_notice = config.get(DAYS_NOTICE) notifier = config.get(NOTIFIER).replace(NOTIFY_DOMAIN + '.', '') countdown = config.get(COUNTDOWN) recurrence = ATTR_DAILY if config.get(DAY): day = config.get(DAY) recurrence = ATTR_MONTHLY if config.get(MONTH): month = config.get(MONTH) recurrence = ATTR_YEARLY if config.get(YEAR): year = config.get(YEAR) calc_date = datetime.datetime.now().replace(second=0, microsecond=0) reminder_set = datetime.datetime.strptime(str(year) + '-' + str(month) + '-' + str(day) + ' ' + str(hour) + ':' + str(minute), '%Y-%m-%d %H:%M') + datetime.timedelta(-days_notice) if calc_date > reminder_set: recurrence = ATTR_PAST_DUE else: recurrence = ATTR_ON_DATE entities.append(DateNotifier(hass, slug, name, hour, minute, day, month, year, message, days_notice, notifier, recurrence, countdown)) @asyncio.coroutine def async_scan_dates_service(call): for entity in component.entities: target_notifiers = [entity] tasks = [notifier.scan_dates() for notifier in target_notifiers] if tasks: yield from asyncio.wait(tasks, loop=hass.loop) else: _LOGGER.error('no tasks initialized') async_track_time_interval(hass, async_scan_dates_service, INTERVAL) yield from component.async_add_entities(entities) return True