How to use pyatmo - 10 common examples

To help you get started, we’ve selected a few pyatmo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / homeassistant / components / netatmo.py View on Github external
def update(self):
        """Call the Netatmo API to update the data."""
        import pyatmo
        self.camera_data = pyatmo.CameraData(self.auth, size=100)
github home-assistant / home-assistant / homeassistant / components / netatmo / __init__.py View on Github external
def update(self):
        """Call the Netatmo API to update the data."""

        self.camera_data = pyatmo.CameraData(self.auth, size=100)
github home-assistant / home-assistant / homeassistant / components / netatmo / climate.py View on Github external
def setup(self):
        """Retrieve HomeData and HomeStatus by NetAtmo API."""
        try:
            self.homedata = pyatmo.HomeData(self.auth)
            self.homestatus = pyatmo.HomeStatus(self.auth, home_id=self.home_id)
            self.home_name = self.homedata.getHomeName(self.home_id)
            self.update()
        except TypeError:
            _LOGGER.error("ThermostatData::setup() got error")
            return False
        return True
github home-assistant / home-assistant / homeassistant / components / netatmo / climate.py View on Github external
def update(self):
        """Call the NetAtmo API to update the data."""
        try:
            self.homestatus = pyatmo.HomeStatus(self.auth, home_id=self.home_id)
        except TypeError:
            _LOGGER.error("Error when getting homestatus")
            return
        except requests.exceptions.Timeout:
            _LOGGER.warning("Timed out when connecting to Netatmo server")
            return
        _LOGGER.debug("Following is the debugging output for homestatus:")
        _LOGGER.debug(self.homestatus.rawData)
        for room in self.homestatus.rooms:
            try:
                roomstatus = {}
                homestatus_room = self.homestatus.rooms[room]
                homedata_room = self.homedata.rooms[self.home_id][room]

                roomstatus["roomID"] = homestatus_room["id"]
                if homestatus_room["reachable"]:
github home-assistant / home-assistant / homeassistant / components / netatmo_public / sensor.py View on Github external
def update(self):
        """Request an update from the Netatmo API."""
        import pyatmo
        data = pyatmo.PublicData(self.auth,
                                 LAT_NE=self.lat_ne,
                                 LON_NE=self.lon_ne,
                                 LAT_SW=self.lat_sw,
                                 LON_SW=self.lon_sw,
                                 filtering=True)

        if data.CountStationInArea() == 0:
            _LOGGER.warning('No Stations available in this area.')
            return

        self.data = data
github home-assistant / home-assistant / homeassistant / components / sensor / netatmo_public.py View on Github external
def update(self):
        """Request an update from the Netatmo API."""
        import pyatmo
        raindata = pyatmo.PublicData(self.auth,
                                     LAT_NE=self.lat_ne,
                                     LON_NE=self.lon_ne,
                                     LAT_SW=self.lat_sw,
                                     LON_SW=self.lon_sw,
                                     required_data_type="rain")

        if raindata.CountStationInArea() == 0:
            _LOGGER.warning('No Rain Station available in this area.')
            return

        raindata_live = raindata.getLive()

        if self.calculation == 'avg':
            self.data = sum(raindata_live.values()) / len(raindata_live)
        else:
            self.data = max(raindata_live.values())
github home-assistant / home-assistant / homeassistant / components / netatmo / sensor.py View on Github external
def update(self):
        """Request an update from the Netatmo API."""
        data = pyatmo.PublicData(
            self.auth,
            LAT_NE=self.lat_ne,
            LON_NE=self.lon_ne,
            LAT_SW=self.lat_sw,
            LON_SW=self.lon_sw,
            filtering=True,
        )

        if data.CountStationInArea() == 0:
            _LOGGER.warning("No Stations available in this area.")
            return

        self.data = data
github home-assistant / home-assistant / homeassistant / components / sensor / netatmo.py View on Github external
if module_name not in data.get_module_names():
                    _LOGGER.error('Module name: "%s" not found', module_name)
                    continue
                # Only create sensors for monitored properties
                for variable in monitored_conditions:
                    dev.append(NetAtmoSensor(data, module_name, variable))
        else:
            for module_name in data.get_module_names():
                for variable in \
                        data.station_data.monitoredConditions(module_name):
                    if variable in SENSOR_TYPES.keys():
                        dev.append(NetAtmoSensor(data, module_name, variable))
                    else:
                        _LOGGER.warning("Ignoring unknown var %s for mod %s",
                                        variable, module_name)
    except pyatmo.NoDevice:
        return None

    add_entities(dev, True)
github home-assistant / home-assistant / homeassistant / components / netatmo / sensor.py View on Github external
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)
github home-assistant / home-assistant / homeassistant / components / netatmo / binary_sensor.py View on Github external
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the access to Netatmo binary sensor."""
    home = config.get(CONF_HOME)
    timeout = config.get(CONF_TIMEOUT)
    if timeout is None:
        timeout = DEFAULT_TIMEOUT

    module_name = None

    auth = hass.data[DATA_NETATMO_AUTH]

    try:
        data = CameraData(hass, auth, home)
        if not data.get_camera_names():
            return None
    except NoDevice:
        return None

    welcome_sensors = config.get(CONF_WELCOME_SENSORS, WELCOME_SENSOR_TYPES)
    presence_sensors = config.get(CONF_PRESENCE_SENSORS, PRESENCE_SENSOR_TYPES)
    tag_sensors = config.get(CONF_TAG_SENSORS, TAG_SENSOR_TYPES)

    for camera_name in data.get_camera_names():
        camera_type = data.get_camera_type(camera=camera_name, home=home)
        if camera_type == "NACamera":
            if CONF_CAMERAS in config:
                if (
                    config[CONF_CAMERAS] != []
                    and camera_name not in config[CONF_CAMERAS]
                ):
                    continue
            for variable in welcome_sensors:

pyatmo

Simple API to access Netatmo weather station data from any Python 3 script. Designed for Home Assistant (but not only)

MIT
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis