Skip to content

Home

Python wrapper to inteact with m2v industrial IoT platform from Eurogard.

Prerequisites

  • Python 3.12+
  • Programmatic access to the Eurogard API

Installation

py2mv is available as a Python package and can be installed via pip or uv.

Via pip

  1. Create a virtual environment: python3 -m venv .venv
  2. Activate the virtual environment: source .venv/bin/active
  3. Install pym2v via pip: pip install pym2v

Via uv

  1. Install pym2v via uv: uv add pym2v

Configuration

To authenticate with the Eurogard API, you need to provide the following credentials:

  • Username
  • Password
  • Client ID
  • Client Secret

You can do this either by using an .env file (recommended) or by setting environment variables directly.

Using an .env file

Rename the .env.example at the root of the project to .env, and replace the placeholder values with your actual credentials.

EUROGARD_BASEURL=https://eurogard.cloud
EUROGARD_USERNAME=your_username_here
EUROGARD_PASSWORD=your_password_here
EUROGARD_CLIENT_ID=your_client_id_here
EUROGARD_CLIENT_SECRET=your_client_secret_here

Usage

Import the EurogardAPI object and create an instance of it

from datetime import datetime, timedelta

from pym2v.api import EurogardAPI


api = EurogardAPI()

Retrieve a list of machines

machines = api.get_machines()

Get the UUID of the machine your are interested in

MACHINE_NAME = "1337Machine"

machine_uuid = api.get_machine_uuid(MACHINE_NAME, machines)

Get the names of measurements for which you like to pull data

result = api.get_machine_measurement_names(machine_uuid)

Turn the data returned by the API into a DataFrame for easier handling

import polars as pl

measurement_names_df = pl.DataFrame(result["entities"])

Get actual data

START_DATE = datetime(2025, 1, 1)
END_DATE = datetime(2025, 1, 13)
INTERVAL = timedelta(seconds=60)
MAX_FRAME_LENGTH = timedelta(days=30)
NAMES = [col.strip() for col in measurement_names_df.get_column("name").to_list()]

data_df = api.get_long_frame_from_names(
    machine_uuid=machine_uuid,
    names=NAMES,
    start=START_DATE,
    end=END_DATE,
    interval=INTERVAL,
    max_frame_length=MAX_FRAME_LENGTH,
)