Fixed entity_id for the script component. Alias now does not override the entity_id

Fixed issue: #561
This commit is contained in:
Stefan Jonasson 2015-10-28 12:27:58 +01:00
parent 0a36c96a55
commit de027609d8
2 changed files with 7 additions and 4 deletions

View File

@ -75,7 +75,7 @@ def setup(hass, config):
_LOGGER.warn("Missing key 'sequence' for script %s", name)
continue
alias = cfg.get(CONF_ALIAS, name)
script = Script(hass, alias, cfg[CONF_SEQUENCE])
script = Script(hass, alias, name, cfg[CONF_SEQUENCE])
component.add_entities((script,))
_, object_id = split_entity_id(script.entity_id)
hass.services.register(DOMAIN, object_id, service_handler)
@ -100,9 +100,10 @@ def setup(hass, config):
class Script(ToggleEntity):
""" Represents a script. """
def __init__(self, hass, name, sequence):
def __init__(self, hass, name, entity_id, sequence):
self.hass = hass
self._name = name
self.entity_id = entity_id
self.sequence = sequence
self._lock = threading.Lock()
self._cur = -1

View File

@ -65,8 +65,10 @@ class EntityComponent(object):
if entity is not None and entity not in self.entities.values():
entity.hass = self.hass
entity.entity_id = generate_entity_id(
self.entity_id_format, entity.name, self.entities.keys())
if entity.entity_id is None:
entity.entity_id = generate_entity_id(
self.entity_id_format, entity.name,
self.entities.keys())
self.entities[entity.entity_id] = entity