mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fixed entity_id for the script component. Alias now does not override the entity_id
Fixed issue: #561
This commit is contained in:
parent
0a36c96a55
commit
de027609d8
@ -75,7 +75,7 @@ def setup(hass, config):
|
|||||||
_LOGGER.warn("Missing key 'sequence' for script %s", name)
|
_LOGGER.warn("Missing key 'sequence' for script %s", name)
|
||||||
continue
|
continue
|
||||||
alias = cfg.get(CONF_ALIAS, name)
|
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,))
|
component.add_entities((script,))
|
||||||
_, object_id = split_entity_id(script.entity_id)
|
_, object_id = split_entity_id(script.entity_id)
|
||||||
hass.services.register(DOMAIN, object_id, service_handler)
|
hass.services.register(DOMAIN, object_id, service_handler)
|
||||||
@ -100,9 +100,10 @@ def setup(hass, config):
|
|||||||
|
|
||||||
class Script(ToggleEntity):
|
class Script(ToggleEntity):
|
||||||
""" Represents a script. """
|
""" Represents a script. """
|
||||||
def __init__(self, hass, name, sequence):
|
def __init__(self, hass, name, entity_id, sequence):
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self.entity_id = entity_id
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
self._cur = -1
|
self._cur = -1
|
||||||
|
@ -65,8 +65,10 @@ class EntityComponent(object):
|
|||||||
if entity is not None and entity not in self.entities.values():
|
if entity is not None and entity not in self.entities.values():
|
||||||
entity.hass = self.hass
|
entity.hass = self.hass
|
||||||
|
|
||||||
|
if entity.entity_id is None:
|
||||||
entity.entity_id = generate_entity_id(
|
entity.entity_id = generate_entity_id(
|
||||||
self.entity_id_format, entity.name, self.entities.keys())
|
self.entity_id_format, entity.name,
|
||||||
|
self.entities.keys())
|
||||||
|
|
||||||
self.entities[entity.entity_id] = entity
|
self.entities[entity.entity_id] = entity
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user