Fixed variable scope issues for entities

This commit is contained in:
NMA 2016-08-25 22:15:31 +05:30
parent ca73295dd1
commit 47a9313fdb

View File

@ -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."""