mirror of
https://github.com/d3vyce/teleinfo-exporter.git
synced 2025-07-06 11:53:45 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
d050b31022 | |||
f457a08404 | |||
02dabe1daa | |||
5da09093f5 | |||
a734ca1979 | |||
73c3e25b91 | |||
9e64905fe3 | |||
e2631e4e3d | |||
0160aa6197 | |||
90f9414d2d |
16
.github/workflows/docker-build-version.yml
vendored
16
.github/workflows/docker-build-version.yml
vendored
@ -5,25 +5,25 @@ on:
|
|||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build docker:
|
build-docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout code
|
- name: checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4.1.1
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to Docker registry
|
- name: Login to Docker registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v5.1.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.REGISTRY }}/${{ github.repository }}:latest,${{ env.REGISTRY }}/${{ github.repository }}:${{ github.ref_name }}
|
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.ref_name }}
|
||||||
|
6
.github/workflows/lint.yml
vendored
6
.github/workflows/lint.yml
vendored
@ -6,11 +6,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4.1.1
|
||||||
- name: Set up Python 3.11
|
- name: Set up Python 3.11
|
||||||
run: |
|
run: |
|
||||||
apt update
|
sudo apt update
|
||||||
apt install -y python3 python3-pip
|
sudo apt install -y python3 python3-pip
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
|
17
.github/workflows/pypi-build-version.yml
vendored
17
.github/workflows/pypi-build-version.yml
vendored
@ -8,27 +8,30 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v4.1.1
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
python3 -m pip install --upgrade pip
|
||||||
sudo apt-get install --yes python3-setuptools python3-wheel
|
python3 -m pip install --upgrade build
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: python3 -m build
|
||||||
python3 -m build
|
- uses: actions/upload-artifact@v4.3.1
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
with:
|
||||||
path: ./dist
|
path: ./dist
|
||||||
name: dist
|
name: dist
|
||||||
pypi-publish:
|
pypi-publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
environment:
|
environment:
|
||||||
name: pypi
|
name: pypi
|
||||||
url: https://pypi.org/p/teleinfo_exporter/
|
url: https://pypi.org/p/teleinfo_exporter/
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v4.1.2
|
||||||
with:
|
with:
|
||||||
path: ./dist
|
path: ./dist
|
||||||
name: dist
|
name: dist
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [1.0.0] - 12-19-2023
|
## 1.1.0 - 02-11-2024
|
||||||
|
add: Grafana dashboard to README
|
||||||
|
fix: MQTT brocker disconnection when client connection timeout
|
||||||
|
|
||||||
Initial release
|
## 1.0.0 - 12-19-2023
|
||||||
|
Initial release
|
||||||
|
10
README.md
10
README.md
@ -1,8 +1,12 @@
|
|||||||
# Teleinfo Exporter
|
# Teleinfo Exporter
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Simple prometheus exporter for Linky teleinfo.
|
Simple prometheus exporter for Linky teleinfo.
|
||||||
Teleinfo Tasmota project :
|
Teleinfo Tasmota project :
|
||||||
https://github.com/NicolasBernaerts/tasmota/tree/master/teleinfo
|
https://github.com/NicolasBernaerts/tasmota/tree/master/teleinfo
|
||||||
|
Grafana Dashboard:
|
||||||
|
https://grafana.com/grafana/dashboards/20182-linky-teleinfo/
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
### Pip
|
### Pip
|
||||||
@ -12,15 +16,11 @@ teleinfo-exporter --help
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
```
|
|
||||||
docker pull teleinfo-exporter
|
|
||||||
```
|
|
||||||
|
|
||||||
Minimal Docker compose:
|
Minimal Docker compose:
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
image: teleinfo_exporter:latest
|
image: ghcr.io/d3vyce/teleinfo-exporter:latest
|
||||||
environment:
|
environment:
|
||||||
- BROKER_HOSTNAME=10.10.0.10
|
- BROKER_HOSTNAME=10.10.0.10
|
||||||
ports:
|
ports:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "teleinfo-exporter"
|
name = "teleinfo-exporter"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bcrypt ~= 4.1",
|
"bcrypt ~= 4.1",
|
||||||
"configargparse ~= 1.7",
|
"configargparse ~= 1.7",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
import time
|
||||||
|
|
||||||
import bcrypt
|
import bcrypt
|
||||||
import configargparse
|
import configargparse
|
||||||
@ -92,6 +93,7 @@ teleinfo_contract_type = Gauge("teleinfo_contract_type", "contract type", ["type
|
|||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc): # pylint: disable=unused-argument
|
def on_connect(client, userdata, flags, rc): # pylint: disable=unused-argument
|
||||||
|
client.subscribe("teleinfo/tele/SENSOR")
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
print("Connected to broker")
|
print("Connected to broker")
|
||||||
else:
|
else:
|
||||||
@ -146,6 +148,16 @@ def on_message(client, userdata, message): # pylint: disable=unused-argument
|
|||||||
teleinfo_contract_type.labels(message["TIC"]["OPTARIF"]).set(0)
|
teleinfo_contract_type.labels(message["TIC"]["OPTARIF"]).set(0)
|
||||||
|
|
||||||
|
|
||||||
|
def on_disconnect(client, userdata, rc): # pylint: disable=unused-argument
|
||||||
|
print("Diconnected from broker, reconnecting...")
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
if not client.reconnect():
|
||||||
|
break
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
@auth.login_required()
|
@auth.login_required()
|
||||||
def global_auth():
|
def global_auth():
|
||||||
@ -186,7 +198,6 @@ def main():
|
|||||||
p.add("--http_cert", help="HTTP Server Certificate", env_var="HTTP_CERT")
|
p.add("--http_cert", help="HTTP Server Certificate", env_var="HTTP_CERT")
|
||||||
p.add("--http_key", help="HTTP Server Key", env_var="HTTP_KEY")
|
p.add("--http_key", help="HTTP Server Key", env_var="HTTP_KEY")
|
||||||
options = p.parse_args()
|
options = p.parse_args()
|
||||||
print(options)
|
|
||||||
|
|
||||||
if options.auth_user and options.auth_hash:
|
if options.auth_user and options.auth_hash:
|
||||||
app.config["USERS"] = {options.auth_user: options.auth_hash.encode()}
|
app.config["USERS"] = {options.auth_user: options.auth_hash.encode()}
|
||||||
@ -198,13 +209,12 @@ def main():
|
|||||||
if options.broker_user and options.broker_password:
|
if options.broker_user and options.broker_password:
|
||||||
client.username_pw_set(options.broker_user, password=options.broker_password)
|
client.username_pw_set(options.broker_user, password=options.broker_password)
|
||||||
|
|
||||||
|
client.connect(options.broker_host, port=options.broker_port)
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_message = on_message
|
client.on_message = on_message
|
||||||
client.connect(options.broker_host, port=options.broker_port)
|
client.on_disconnect = on_disconnect
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
|
|
||||||
client.subscribe(options.broker_topic)
|
|
||||||
|
|
||||||
if options.http_cert and options.http_key:
|
if options.http_cert and options.http_key:
|
||||||
ssl_context = (options.http_cert, options.http_key)
|
ssl_context = (options.http_cert, options.http_key)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user