def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the alarm platform.""" name = config[CONF_NAME] username = config[CONF_USERNAME] password = config[CONF_PASSWORD] area_id = config[CONF_AREA_ID] additional = config[CONF_ADDITIONAL] try: client = YaleSmartAlarmClient(username, password, area_id) except AuthenticationError: _LOGGER.error ("Authentication failed. Check credentials") return object_status = client._get_authenticated(_ENDPOINT_DEVICES_STATUS) for object in object_status['data']: if (additional): add_entities([ YaleBinarySensor2(hass, client, object['name'], object['type'].replace( 'device_type.', ''), object) ], True) elif object['type'] == "device_type.door_contact": add_entities([ YaleBinarySensor2(hass, client, object['name'], object['type'].replace( 'device_type.', ''), object) ], True)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the alarm platform.""" name = config[CONF_NAME] username = config[CONF_USERNAME] password = config[CONF_PASSWORD] area_id = config[CONF_AREA_ID] try: client = YaleSmartAlarmClient(username, password, area_id) except AuthenticationError: _LOGGER.error ("Authentication failed. Check credentials") return doors = client.get_doors_status() status = client._get_authenticated("/api/panel/device_status/") for door in doors: add_entities([YaleBinarySensor(hass, client, door, doors)], True)