Add missing teleinfo library. Use Python3.
This commit is contained in:
parent
bcb565a559
commit
3008197732
@ -3,6 +3,8 @@ MAINTAINER yohan <783b8c87@scimetis.net>
|
|||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
ENV TZ Europe/Paris
|
ENV TZ Europe/Paris
|
||||||
RUN apt-get update && apt-get -y install gunicorn sqlite3 python3-pip python3-requests python3-yaml python3-flask python3-serial udev
|
RUN apt-get update && apt-get -y install gunicorn sqlite3 python3-pip python3-requests python3-yaml python3-flask python3-serial udev
|
||||||
|
ENV PIP_BREAK_SYSTEM_PACKAGES 1
|
||||||
|
RUN pip install teleinfo
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
COPY find_ttyUSB.sh /root/
|
COPY find_ttyUSB.sh /root/
|
||||||
COPY read_one-wire_sensor.py /root/
|
COPY read_one-wire_sensor.py /root/
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# # pip install teleinfo
|
# # pip install teleinfo
|
||||||
# https://pypi.org/project/teleinfo/
|
# https://pypi.org/project/teleinfo/
|
||||||
# https://www.magdiblog.fr/gpio/teleinfo-edf-suivi-conso-de-votre-compteur-electrique/
|
# https://www.magdiblog.fr/gpio/teleinfo-edf-suivi-conso-de-votre-compteur-electrique/
|
||||||
@ -30,20 +29,20 @@ ti = Parser(UTInfo2(port=device))
|
|||||||
res = ti.get_frame()
|
res = ti.get_frame()
|
||||||
|
|
||||||
if args.format == 'human-readable':
|
if args.format == 'human-readable':
|
||||||
print "Puissance apparente compteur : "+str(int(res['PAPP']))+"VA"
|
print("Puissance apparente compteur : "+str(int(res['PAPP']))+"VA")
|
||||||
# moins précis car Intensité arrondie à l'entier
|
# moins précis car Intensité arrondie à l'entier
|
||||||
print "Puissance apparente calculée : "+str(int(res['IINST'])*230)+"VA"
|
print("Puissance apparente calculée : "+str(int(res['IINST'])*230)+"VA")
|
||||||
print "Puissance souscrite : 6kVA"
|
print("Puissance souscrite : 6kVA")
|
||||||
print "Puissance max avant coupure (marge 30%) : 7,8kVA"
|
print("Puissance max avant coupure (marge 30%) : 7,8kVA")
|
||||||
print "Intensité : "+str(int(res['IINST']))+"A"
|
print("Intensité : "+str(int(res['IINST']))+"A")
|
||||||
print "Intensité abonnement : "+str(int(res['ISOUSC']))+"A"
|
print("Intensité abonnement : "+str(int(res['ISOUSC']))+"A")
|
||||||
print "Consommation : "+str(int(res['BASE']))+"Wh"
|
print("Consommation : "+str(int(res['BASE']))+"Wh")
|
||||||
elif args.format == 'raw_json':
|
elif args.format == 'raw_json':
|
||||||
print json.dumps(res)
|
print(json.dumps(res))
|
||||||
elif args.format == 'custom_json':
|
elif args.format == 'custom_json':
|
||||||
data = {}
|
data = {}
|
||||||
data['Modane_elec_main_power'] = int(res['PAPP'])
|
data['Modane_elec_main_power'] = int(res['PAPP'])
|
||||||
data['Modane_elec_energy_index'] = int(res['BASE'])
|
data['Modane_elec_energy_index'] = int(res['BASE'])
|
||||||
print json.dumps(data)
|
print(json.dumps(data))
|
||||||
#for frame in ti:
|
#for frame in ti:
|
||||||
# print frame
|
# print(frame)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
Loading…
Reference in New Issue
Block a user