Ensure generate_entity_id returns valid entity ids

pull/158/head
Paulus Schoutsen 2015-06-01 22:55:33 -07:00
parent a557cf388b
commit 66a380dd8e
1 changed files with 3 additions and 1 deletions

View File

@ -2,7 +2,8 @@
Helper methods for components within Home Assistant.
"""
from homeassistant.loader import get_component
from homeassistant.const import ATTR_ENTITY_ID, CONF_PLATFORM
from homeassistant.const import (
ATTR_ENTITY_ID, CONF_PLATFORM, DEVICE_DEFAULT_NAME)
from homeassistant.util import ensure_unique_string, slugify
# Deprecated 3/5/2015 - Moved to homeassistant.helpers.entity
@ -12,6 +13,7 @@ from .entity import Entity as Device, ToggleEntity as ToggleDevice # noqa
def generate_entity_id(entity_id_format, name, current_ids=None, hass=None):
""" Generate a unique entity ID based on given entity IDs or used ids. """
name = name.lower() or DEVICE_DEFAULT_NAME.lower()
if current_ids is None:
if hass is None:
raise RuntimeError("Missing required parameter currentids or hass")