Skip to main content

Python Wrapper to communicate with a Meteobridge Weather Data Logger

Project description

Python Wrapper for Meteobridge Datalogger

Latest PyPI version Supported Python

This module communicates with a Meteobridge Datalogger using their Template Script.

The module is primarily written for the purpose of being used in Home Assistant for the Custom Integration called meteobridge but might be used for other purposes also.

Install

pymeteobridgedata is avaible on PyPi:

pip install pymeteobridgedata

Usage

This library is primarily designed to be used in an async context.

The main interface for the library is the pymeteobridgedata.MeteobridgeApiClient. This interface takes 6 options:

  • username: (required) The username to login to your Meteobridge device. Default this meteobridge.
  • password: (required) The password for your meteobridge device.
  • ip_address: (required) IP Address of the Meteobridge device.
  • units: (optional) Valid options here are metric or imperial. Metebridge devices always deliver data in metric units, so conversion will only take place if if metric is not selected. Default value is metric
  • extra_sensors: (optional) Number of extra sensors attached to the Meteobridge Logger (Default is 0, max is 7)
  • homeassistant: (optional) Valid options are True or False. If set to True, there will be some unit types that will not be converted, as Home Assistant will take care of that. Default value is True

Example Python script

import asyncio
import logging
import time

from pymeteobridgedata import MeteobridgeApiClient, Invalid, NotAuthorized, BadRequest
from pymeteobridgedata.data import DataLoggerDescription, ObservationDescription

_LOGGER = logging.getLogger(__name__)

async def main() -> None:
    logging.basicConfig(level=logging.DEBUG)
    start = time.time()

    meteobridge = MeteobridgeApiClient(USERNAME, PASSWORD, IP_ADDRESS, homeassistant=False, units="imperial", extra_sensors=0)
    try:
        await meteobridge.initialize()

    except Invalid as err:
        _LOGGER.debug(err)
    except NotAuthorized as err:
        _LOGGER.debug(err)
    except BadRequest as err:
        _LOGGER.debug(err)

    data: DataLoggerDescription = meteobridge.device_data
    if data is not None:
        for field in data.__dataclass_fields__:
            value = getattr(data, field)
            print(field,"-", value)

    data: ObservationDescription = await meteobridge.update_observations()
    if data is not None:
        for field in data.__dataclass_fields__:
            value = getattr(data, field)
            print(field,"-", value)


    end = time.time()

    await meteobridge.req.close()

    _LOGGER.info("Execution time: %s seconds", end - start)

asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymeteobridgedata-0.1.16.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

pymeteobridgedata-0.1.16-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file pymeteobridgedata-0.1.16.tar.gz.

File metadata

  • Download URL: pymeteobridgedata-0.1.16.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pymeteobridgedata-0.1.16.tar.gz
Algorithm Hash digest
SHA256 1582943e69bdabae62aa4d47e9cd1ae8580752a67b4d4252f029d0325deb1a7e
MD5 ba3475356754059659050eda299f1458
BLAKE2b-256 0a1819abc06e0d75e26337b1c0322c407e9231b22daab9f925360ed009cd455a

See more details on using hashes here.

File details

Details for the file pymeteobridgedata-0.1.16-py3-none-any.whl.

File metadata

  • Download URL: pymeteobridgedata-0.1.16-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pymeteobridgedata-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 3352b17984576eb45d4bbdf14526f9f71b708afc3b7b0ca4e0f36b6fca203fc3
MD5 be13800387c797d78f5d6c200c40ed6d
BLAKE2b-256 3635d30642f61ac9bf8460a79861e1fe2baf7cda3f4560cb38e78dc41895731c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page