Serial Teleinfo
This project provides Python utilities to access data from Enedis energy meters using a serial converter :
serial_teleinfoprovides the classes to read and parse dataserial_teleinfo.serveris a simple web-server to access live readings through a JSON api
You will need a serial adapter such as the Micro Teleinfo to use this package.
Running the server
The web server exposes a JSON API providing live data read from the energy meter :
{
"connected":true,
"ready":true,
"values":{
"ISOUSC": [30, "A"],
"BASE": [804220, "Wh"],
"PTEC": ["TH", null],
"IINST": [1, "A"],
"IMAX": [90, "A"],
"PAPP": [340, "VA"],
"HHPHC": ["A", null],
"MOTDETAT": ["000000", null],
"ADCO": ["012345678901", null],
"OPTARIF": ["BASE", null]
}
}
Configuration file
The configuration is as follows :
[teleinfo]
device=/dev/ttyUSB0
loglevel=INFO
[http]
listen=127.0.0.1:8000
[users]
apiuser=apipassword
teleinfo/device: The path to the serial port.teleinfo/loglevel(optionnal) : Modifies the log verbosity, it can beDEBUG,INFO,WARNING,ERROR. Default isINFO.http/listen: The host and port to listen to.users: A list of user/password allowed to use the API (using basic authentification).
Using python
Install the package :
pip install serial-teleinfo[server]
Create a configuration file teleinfo.ini as described above and run the command :
python -m serial_teleinfo.server teleinfo.ini
Once the server is running, you can access the values at http://apiuser:apipassword@localhost:8000/status.json.
Using Docker
A docker image is provided, here's an example docker-compose.yml :
version: '3'
services:
teleinfo:
image: ugomeda/serial-teleinfo
restart: always
devices:
- /dev/ttyUSB0
environment:
HTTP_LISTEN: "0.0.0.0:7777"
USERS_PASSWORD: "Str0ngPa55w0rd!"
TELEINFO_LOGLEVEL: "DEBUG"
ports:
- "7777:7777"
You can access the values at http://apiuser:Str0ngPa55w0rd!@SERVERIP:7777/status.json.
The environment variables are :
| Variable | Default value |
|---|---|
| TELEINFO_DEVICE | /dev/ttyUSB0 |
| TELEINFO_LOGLEVEL | INFO |
| HTTP_LISTEN | 0.0.0.0:8000 |
| USERS_USER | apiuser |
| USERS_PASSWORD | apipassword |
Using the library
Install the package :
pip install serial-teleinfo
serial_teleinfo.Client
This class provides direct access to the values read on the serial port.
Here's an example usage :
import serial
from serial_teleinfo import Client, TeleinfoException
try:
with Client("/dev/ttyUSB0") as client:
while True:
print(client.read_value())
except TeleinfoException as e:
print(e)
except serial.SerialException as e:
print(e)
You can also refer to the serial_teleinfo.ValueUpdater implementation.
serial_teleinfo.ValueUpdater
This utility class manages a background thread to update values indefinitely. It will automatically handle reconnection to the serial port and ignore temporary errors or reccuring unknown keys.
It provides 3 main properties :
values: A dictionary with all the valuesconnected: True if the client is connected to the meterready: True if all the values are available
You can also override the update_value method to access the read values as they are read.
Heres an example usage :
import time
from serial_teleinfo import ValueUpdater
class MyValueUpdater(ValueUpdater):
def update_value(self, value):
print(f"Updated {value.key}")
super().update_value(value)
updater = MyValueUpdater("/dev/ttyUSB0")
updater.start()
try:
while True:
print(f"Connected : {updater.connected}")
print(f"Ready : {updater.ready}")
for value in updater.values.values():
print(value)
time.sleep(2)
finally:
updater.stop()
Metadata
Release files for serial-teleinfo 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| serial-teleinfo-1.0.1.tar.gz | 8.8 kB | Without provenance | Details for serial-teleinfo-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| serial_teleinfo-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for serial_teleinfo-1.0.1-py3-none-any.whl |
Total release size: 20.0 kB
Release files / serial-teleinfo-1.0.1.tar.gz
| Download URL | serial-teleinfo-1.0.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce100cc4454bf55a18ae2e53aa83913b58c52eddb9f9d76dc83bd53c5b78c38f
|
|
BLAKE2b-256 checksum How to use checksums |
14fbd6c9b17531ff1f63aea3d3973f45b4bd2102e1a72572436223e30cd0b63f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
|
Release files / serial_teleinfo-1.0.1-py3-none-any.whl
| Download URL | serial_teleinfo-1.0.1-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4de1da74878a22062385aa40b11064a733cb874fd604629305c3474ea2a2e2a
|
|
BLAKE2b-256 checksum How to use checksums |
f81b0e679172057e589fadc88074e63c385bd8d15467be4d1a60faff2ed32764
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
|
Security for serial-teleinfo 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.