mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fixed variable scope issues for entities
This commit is contained in:
parent
ca73295dd1
commit
47a9313fdb
@ -29,7 +29,6 @@ DEFAULT_PASSIVE = False
|
|||||||
ICON_HOME = 'mdi:home'
|
ICON_HOME = 'mdi:home'
|
||||||
ICON_IMPORT = 'mdi:import'
|
ICON_IMPORT = 'mdi:import'
|
||||||
|
|
||||||
entities = set()
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -112,9 +111,11 @@ def setup(hass, config):
|
|||||||
|
|
||||||
# Add a zone to the existing set
|
# Add a zone to the existing set
|
||||||
def add_zone(hass, name, latitude, longitude, radius):
|
def add_zone(hass, name, latitude, longitude, radius):
|
||||||
"""Add a zone from other components"""
|
"""Add a zone from other components."""
|
||||||
_LOGGER.info("Adding new zone %s", name)
|
_LOGGER.info("Adding new zone %s", name)
|
||||||
if name not in entities:
|
entities = set()
|
||||||
|
|
||||||
|
if hass.states.get('zone.' + name) is None:
|
||||||
zone = Zone(hass, name, latitude, longitude, radius, ICON_IMPORT,
|
zone = Zone(hass, name, latitude, longitude, radius, ICON_IMPORT,
|
||||||
False, True)
|
False, True)
|
||||||
zone.entity_id = generate_entity_id(ENTITY_ID_FORMAT, name,
|
zone.entity_id = generate_entity_id(ENTITY_ID_FORMAT, name,
|
||||||
@ -124,7 +125,6 @@ def add_zone(hass, name, latitude, longitude, radius):
|
|||||||
else:
|
else:
|
||||||
_LOGGER.info("Zone already exists")
|
_LOGGER.info("Zone already exists")
|
||||||
|
|
||||||
|
|
||||||
class Zone(Entity):
|
class Zone(Entity):
|
||||||
"""Representation of a Zone."""
|
"""Representation of a Zone."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user