def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Obihai sensor platform.""" username = config[CONF_USERNAME] password = config[CONF_PASSWORD] host = config[CONF_HOST] sensors = [] pyobihai = PyObihai(host, username, password) login = pyobihai.check_account() if not login: _LOGGER.error("Invalid credentials") return serial = pyobihai.get_device_serial() services = pyobihai.get_state() line_services = pyobihai.get_line_state() call_direction = pyobihai.get_call_direction() for key in services: sensors.append(ObihaiServiceSensors(pyobihai, serial, key)) if line_services is not None: for key in line_services: sensors.append(ObihaiServiceSensors(pyobihai, serial, key)) for key in call_direction: sensors.append(ObihaiServiceSensors(pyobihai, serial, key)) add_entities(sensors)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Obihai sensor platform.""" username = config[CONF_USERNAME] password = config[CONF_PASSWORD] host = config[CONF_HOST] sensors = [] pyobihai = PyObihai() services = pyobihai.get_state(host, username, password) line_services = pyobihai.get_line_state(host, username, password) for key in services: sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key)) for key in line_services: sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key)) add_entities(sensors)