Ensure generate_entity_id returns valid entity ids
parent
a557cf388b
commit
66a380dd8e
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue