Skip to main content

A Python wrapper to read out sensors from Technische Alternative using the C.M.I.

Project description

TA-CMI

A Python wrapper to read out sensors from Technische Alternative using the C.M.I.

How to use package

Json API

import asyncio

from ta_cmi import CMI, Languages, ApiError, RateLimitError, InvalidCredentialsError, InvalidDeviceError, ChannelType


async def main():
    try:
        cmi = CMI("http://192.168.1.101", "admin", "admin")

        devices = await cmi.get_devices()

        device = devices[0]

        # Set type automatically
        await device.fetch_type()

        # Set type manually
        device.set_device_type("UVR16x2")

        await device.update()

        print(str(device))

        inputChannels = device.get_channels(ChannelType.INPUT)
        outputChannels = device.get_channels(ChannelType.OUTPUT)
        analogLogging = device.get_channels(ChannelType.ANALOG_LOGGING)

        for i in inputChannels:
            ch = inputChannels.get(i)
            print(str(ch))

        for o in outputChannels:
            ch = outputChannels.get(o)
            print(f"{str(ch)} - {ch.get_unit(Languages.DE)}")

        for al in analogLogging:
            ch = analogLogging.get(al)
            print(f"{str(ch)} - {ch.get_unit(Languages.DE)}")

    except (ApiError, RateLimitError, InvalidCredentialsError, InvalidDeviceError) as error:
        print(f"Error: {error}")


loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()

Supported data types

Device type Inputs Outputs DL-inputs System-values: General System-values: Date System-values: Time System-values: Sun System-values: Electrical power Analog network inputs Digital network inputs M-Bus Modbus KNX Analog logging Digital logging
UVR1611
UVR16x2
RSM610
CAN-I/O45
CAN-EZ2
CAN-MTx2
CAN-BC2
UVR65
CAN-EZ3
UVR610
UVR67

Note The supported data types may differ from the official API. If a device type supports other data types than listed here, please create an issue.

CoE Server

Data can be retrieved using this CoE to HTTP server

import asyncio

from ta_cmi import (
    ApiError,
    ChannelMode,
    CoE,
    InvalidCredentialsError,
    InvalidDeviceError,
    Languages,
    RateLimitError,
)


async def main():
    try:
        coe = CoE("http://192.168.2.201:9000")
        
        can_id = 42

        await coe.update(can_id)

        analog_channels = coe.get_channels(can_id, ChannelMode.ANALOG)
        digital_channels = coe.get_channels(can_id, ChannelMode.DIGITAL)

        for i in analog_channels:
            ch = analog_channels.get(i)
            print(str(ch))

        for o in digital_channels:
            ch = digital_channels.get(o)
            print(f"{str(ch)} - {ch.get_unit(Languages.DE)}")

    except (ApiError, RateLimitError, InvalidCredentialsError, InvalidDeviceError) as error:
        print(f"Error: {error}")


loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()

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

ta_cmi-3.4.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ta_cmi-3.4.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file ta_cmi-3.4.0.tar.gz.

File metadata

  • Download URL: ta_cmi-3.4.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.22

File hashes

Hashes for ta_cmi-3.4.0.tar.gz
Algorithm Hash digest
SHA256 e061ad20294d876b3fe343b218e16ad5b97d9aa345c09786400f3ecd26300e20
MD5 f85de7aac379ff659ad231ac40337b39
BLAKE2b-256 3578bdcf00aa4e07604b6cf555abfa7951dda1a452d3cc5a8d31b50f7a1c31e4

See more details on using hashes here.

File details

Details for the file ta_cmi-3.4.0-py3-none-any.whl.

File metadata

  • Download URL: ta_cmi-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.22

File hashes

Hashes for ta_cmi-3.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c539366cbdad9f1e58ec4e0581c5f49f2a2f990ee2ab602ff63b3c0767a39a6
MD5 17a71805d80d7ae581880e81435806ee
BLAKE2b-256 1126871a8ef1720aa162dbbcf29808a0b62ecec58ef92a33d7e6d86c7ad1d606

See more details on using hashes here.

Supported by

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