Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
moduleId=module["id"]
):
entities.append(NetatmoSensor(data, module, condition.lower()))
return entities
def _retry(_data):
try:
entities = find_devices(_data)
except requests.exceptions.Timeout:
return call_later(
hass, NETATMO_UPDATE_INTERVAL, lambda _: _retry(_data)
)
if entities:
add_entities(entities, True)
for data_class in [pyatmo.WeatherStationData, pyatmo.HomeCoachData]:
try:
data = NetatmoData(auth, data_class, config.get(CONF_STATION))
except pyatmo.NoDevice:
_LOGGER.info(
"No %s devices found", NETATMO_DEVICE_TYPES[data_class.__name__]
)
continue
try:
dev.extend(find_devices(data))
except requests.exceptions.Timeout:
call_later(hass, NETATMO_UPDATE_INTERVAL, lambda _: _retry(data))
if dev:
add_entities(dev, True)
def _detect_platform_type(self):
"""Return the XXXData object corresponding to the specified platform.
The return can be a WeatherStationData or a HomeCoachData.
"""
import pyatmo
for data_class in [pyatmo.WeatherStationData, pyatmo.HomeCoachData]:
try:
station_data = data_class(self.auth)
_LOGGER.debug("%s detected!", str(data_class.__name__))
return station_data
except TypeError:
continue