def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Concord232 binary sensor platform.""" from concord232 import client as concord232_client host = config.get(CONF_HOST) port = config.get(CONF_PORT) exclude = config.get(CONF_EXCLUDE_ZONES) zone_types = config.get(CONF_ZONE_TYPES) sensors = [] try: _LOGGER.debug('Initializing Client.') client = concord232_client.Client('http://{}:{}'.format(host, port)) client.zones = client.list_zones() client.last_zone_update = datetime.datetime.now() except requests.exceptions.ConnectionError as ex: _LOGGER.error('Unable to connect to Concord232: %s', str(ex)) return False for zone in client.zones: _LOGGER.info('Loading Zone found: %s', zone['name']) if zone['number'] not in exclude: sensors.append( Concord232ZoneSensor( hass, client, zone, zone_types.get(zone['number'], get_opening_type(zone)))) add_devices(sensors) return True
def __init__(self, url, name, code, mode): """Initialize the Concord232 alarm panel.""" self._attr_name = name self._code = code self._mode = mode self._url = url self._alarm = concord232_client.Client(self._url) self._alarm.partitions = self._alarm.list_partitions()
def __init__(self, url, name): """Initialize the Concord232 alarm panel.""" from concord232 import client as concord232_client self._state = None self._name = name self._url = url self._alarm = concord232_client.Client(self._url) self._alarm.partitions = self._alarm.list_partitions() self._alarm.last_partition_update = datetime.datetime.now()
def __init__(self, url, name, code, mode): """Initialize the Concord232 alarm panel.""" from concord232 import client as concord232_client self._state = None self._name = name self._code = code self._mode = mode self._url = url self._alarm = concord232_client.Client(self._url) self._alarm.partitions = self._alarm.list_partitions()
def __init__(self, hass, url, name): """Initialize the Concord232 alarm panel.""" from concord232 import client as concord232_client self._state = STATE_UNKNOWN self._hass = hass self._name = name self._url = url try: client = concord232_client.Client(self._url) except requests.exceptions.ConnectionError as ex: _LOGGER.error("Unable to connect to Concord232: %s", str(ex)) self._alarm = client self._alarm.partitions = self._alarm.list_partitions() self._alarm.last_partition_update = datetime.datetime.now() self.update()
def setup_platform( hass: HomeAssistant, config: ConfigType, add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the Concord232 binary sensor platform.""" host = config[CONF_HOST] port = config[CONF_PORT] exclude = config[CONF_EXCLUDE_ZONES] zone_types = config[CONF_ZONE_TYPES] sensors = [] try: _LOGGER.debug("Initializing client") client = concord232_client.Client(f"http://{host}:{port}") client.zones = client.list_zones() client.last_zone_update = dt_util.utcnow() except requests.exceptions.ConnectionError as ex: _LOGGER.error("Unable to connect to Concord232: %s", str(ex)) return # The order of zones returned by client.list_zones() can vary. # When the zones are not named, this can result in the same entity # name mapping to different sensors in an unpredictable way. Sort # the zones by zone number to prevent this. client.zones.sort(key=lambda zone: zone["number"]) for zone in client.zones: _LOGGER.info("Loading Zone found: %s", zone["name"]) if zone["number"] not in exclude: sensors.append( Concord232ZoneSensor( hass, client, zone, zone_types.get(zone["number"], get_opening_type(zone)), ) ) add_entities(sensors, True)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Concord232 binary sensor platform.""" from concord232 import client as concord232_client host = config.get(CONF_HOST) port = config.get(CONF_PORT) exclude = config.get(CONF_EXCLUDE_ZONES) zone_types = config.get(CONF_ZONE_TYPES) sensors = [] try: _LOGGER.debug("Initializing client") client = concord232_client.Client("http://{}:{}".format(host, port)) client.zones = client.list_zones() client.last_zone_update = datetime.datetime.now() except requests.exceptions.ConnectionError as ex: _LOGGER.error("Unable to connect to Concord232: %s", str(ex)) return False # The order of zones returned by client.list_zones() can vary. # When the zones are not named, this can result in the same entity # name mapping to different sensors in an unpredictable way. Sort # the zones by zone number to prevent this. client.zones.sort(key=lambda zone: zone["number"]) for zone in client.zones: _LOGGER.info("Loading Zone found: %s", zone["name"]) if zone["number"] not in exclude: sensors.append( Concord232ZoneSensor( hass, client, zone, zone_types.get(zone["number"], get_opening_type(zone)), )) add_entities(sensors, True)