je viens de faire un .bat pour windows sur gazpar https://github.com/empierre/domoticz_gaspar
celui de linky je le ferai peut-être mais bientôt cela ne fonctionnera plus avec leur nouveau site...
je viens de faire un .bat pour windows sur gazpar https://github.com/empierre/domoticz_gaspar
Hello,
Il s'agit apparemment d'une anomalie connuedenis_brasseur a écrit : ↑28 sept. 2019, 15:59.......................
.......................................
........................................................
Egalement un message récurrent dans les logs, mais qui n'est apapru qu'au bout de 30 mn environCode : Tout sélectionner
2019-09-28 16:11:50.055 Error: (D2L) 'onHeartbeat' failed 'TypeError':'attribute of type 'NoneType' is not callable'. 2019-09-28 16:11:50.055 Error: (D2L) ----> Line 158 in '/home/pi/domoticz/plugins/LinkyD2L/plugin.py', function onHeartbeat 2019-09-28 16:11:50.055 Error: (D2L) ----> Line 107 in '/home/pi/domoticz/plugins/LinkyD2L/plugin.py', function onHeartbeat
Code : Tout sélectionner
# dat0 = datetime.datetime.strptime(ix0[0],'%Y-%m-%dT%H:%M:%S')
try:
dat0 = datetime.strptime(ix0[0], '%Y-%m-%dT%H:%M:%S')
except TypeError:
dat0 = datetime.fromtimestamp(time.mktime(time.strptime(ix0[0], '%Y-%m-%dT%H:%M:%S')))
# dat1 = datetime.datetime.strptime(ix1[0],'%Y-%m-%dT%H:%M:%S')
try:
dat1 = datetime.strptime(ix1[0], '%Y-%m-%dT%H:%M:%S')
except TypeError:
dat1 = datetime.fromtimestamp(time.mktime(time.strptime(ix1[0], '%Y-%m-%dT%H:%M:%S')))
Code : Tout sélectionner
#
# Author: Philou55 sur base GizMoCuz
#
# Integration Domoticz de l ERL D2L pour le compteur Linky
#
"""
<plugin key="LinkyD2L" name="D2L pour Linky" author="Philou55" version="1.0.0">
<description>
Declarez le D2L avec vos identifiants ConsoSpy et vous obtiendrez
<ul style="list-style-type:square">
<li>votre index de relève en temps réel</li>
</ul>
</description>
<params>
<param field="Username" label="Identifiant" width="100px" required="true" default=""/>
<param field="Password" label="mot de passe" width="100px" required="true" default=""/>
<param field="Mode1" label="Scan Delay (mn)" width="20px" required="true" default="1"/>
<param field="Mode2" label="Debug Y/N" width="20px" required="true" default="N"/>
</params>
</plugin>
"""
import Domoticz
import json
import os
from datetime import datetime
import time
#import requests
class BasePlugin:
# controle du heartbeat
flag01 = 0
nflag01 = 6
sMins = None
path = None
sUser = None
sPassword = None
sDebug = None
debug = False
def __init__(self):
#self.var = 123
return
def onStart(self):
self.flag01=0
# self.nflag01 = int(Parameters["Frequence"])
Domoticz.Heartbeat(20)
self.path=os.getcwd() + "/plugins/LinkyD2L"
self.sUser=Parameters["Username"]
self.sPassword=Parameters["Password"]
self.sMins=Parameters["Mode1"]
self.nflag01 = int(self.sMins) * 3
self.sDebug=Parameters["Mode2"].upper()
if self.sDebug == "Y" : self.debug=True
Domoticz.Log("START with (" + self.sUser+","+self.sPassword+") scan every "+self.sMins+" mn ("+str(self.nflag01)+ "HB) , Debug="+self.sDebug)
if(len(Devices)==0):
Domoticz.Device(Name="LKY_IndexKWH", Unit=1, TypeName="Custom", Used=1).Create()
Domoticz.Device(Name="LKY_Amperes", Unit=2, TypeName="Current/Ampere", Used=1).Create()
Domoticz.Device(Name="LKY_Watts", Unit=3, TypeName="kWh", Used=1).Create()
if self.debug: DumpConfigToLog()
def onStop(self):
Domoticz.Log("onStop called")
def onConnect(self, Connection, Status, Description):
Domoticz.Log("onConnect called")
def onMessage(self, Connection, Data):
Domoticz.Log("onMessage called")
def onCommand(self, Unit, Command, Level, Hue):
Domoticz.Log("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
def onNotification(self, Name, Subject, Text, Status, Priority, Sound, ImageFile):
Domoticz.Log("Notification: " + Name + "," + Subject + "," + Text + "," + Status + "," + str(Priority) + "," + Sound + "," + ImageFile)
def onDisconnect(self, Connection):
Domoticz.Log("onDisconnect called")
def onHeartbeat(self):
if self.flag01 == 0:
script=self.path + "/D2L.py"
res=os.system("python " + script + " " + self.sUser + " "+ self.sPassword)
if self.debug: Domoticz.Log(script+"Result is "+str(res))
fichier=(self.path + "/" + "D2L.json")
if os.path.isfile(fichier):
with open(fichier) as json_file:
data = json.load(json_file)
# print (data)
# Domoticz.Log(data['Heure']+"="+data['Index'])
# index recupere par GetIndexBetween
try:
ix0=data['Index0'].split("=")
nValue=float(ix0[1])/1000.
#Domoticz.Log(str(nValue)+ " Kwh")
Devices[1].Update(nValue=int(data['Index']),sValue=str(nValue))
except:
Domoticz.Log("Erreur calcul Index")
# intensite du courant
try:
sValue2=data['Courant']+";0;0"
Devices[2].Update(nValue=int(data['Courant']),sValue=sValue2)
# Domoticz.Log(Devices[2].Name+" : "+sValue2)
# calcul de la puissance en WH
except:
Domoticz.Log("Erreur calcul Courant")
try:
ix1=data['Index1'].split("=")
conso=int(ix0[1]) - int(ix1[1])
try:
dat0 = datetime.strptime(ix0[0], '%Y-%m-%dT%H:%M:%S')
except TypeError:
dat0 = datetime.fromtimestamp(time.mktime(time.strptime(ix0[0], '%Y-%m-%dT%H:%M:%S')))
try:
dat1 = datetime.strptime(ix1[0], '%Y-%m-%dT%H:%M:%S')
except TypeError:
dat1 = datetime.fromtimestamp(time.mktime(time.strptime(ix1[0], '%Y-%m-%dT%H:%M:%S')))
duree=(dat0-dat1).seconds
if int(duree) != 0 :
instantwatt=float(conso)*3600/float(duree)
# Domoticz.Log("Conso:"+str(conso)+" de "+ix1[0]+" a "+ix0[0]+" soit "+ str(duree)+ "==> " +str(instantwatt))
sValue3=str(instantwatt)+";"+str(nValue*1000)
Devices[3].Update(nValue=0,sValue=sValue3)
# Domoticz.Log(Devices[3].Name+" ==> "+sValue3)
except:
Domoticz.Log("Erreur calcul Puissance")
else:
Domoticz.Log("fichier D2L.txt inexistant")
self.flag01 = self.flag01 + 1
if self.flag01 >= self.nflag01: self.flag01=0
global _plugin
_plugin = BasePlugin()
def onStart():
global _plugin
_plugin.onStart()
def onStop():
global _plugin
_plugin.onStop()
def onConnect(Connection, Status, Description):
global _plugin
_plugin.onConnect(Connection, Status, Description)
def onMessage(Connection, Data):
global _plugin
_plugin.onMessage(Connection, Data)
def onCommand(Unit, Command, Level, Hue):
global _plugin
_plugin.onCommand(Unit, Command, Level, Hue)
def onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile):
global _plugin
_plugin.onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile)
def onDisconnect(Connection):
global _plugin
_plugin.onDisconnect(Connection)
def onHeartbeat():
global _plugin
_plugin.onHeartbeat()
# Generic helper functions
def DumpConfigToLog():
for x in Parameters:
if Parameters[x] != "":
Domoticz.Log( "'" + x + "':'" + str(Parameters[x]) + "'")
Domoticz.Log("Device count: " + str(len(Devices)))
for x in Devices:
Domoticz.Log("Device: " + str(x) + " - " + str(Devices[x]))
Domoticz.Log("Device ID: '" + str(Devices[x].ID) + "'")
Domoticz.Log("Device Name: '" + Devices[x].Name + "'")
Domoticz.Log("Device nValue: " + str(Devices[x].nValue))
Domoticz.Log("Device sValue: '" + Devices[x].sValue + "'")
Domoticz.Log("Device LastLevel: " + str(Devices[x].LastLevel))
return
Les erreurs que je rencontrais proviennent du fait que quelques valeurs ne remontent pas de mon D2L vers consospy.philou55 a écrit : ↑14 oct. 2019, 20:27Merci de cette contribution ...
Je n'ai pas le problème sur mon installation, il faudra qu'on comprenne nos différences
Je ne suis pas en mesure d'évaluer le code sur mon installation (vivent les vacances)
Mais si il est sans conséquence, je mettrai en ligne cette version dans le GitHub
Encore une fois, Merci !!!
Code : Tout sélectionner
sValue2=data['Courant']+";0;0"
Devices[2].Update(nValue=int(data['Courant']),sValue=sValue2)
Code : Tout sélectionner
try:
sValue2=data['Courant']+";0;0"
Devices[2].Update(nValue=int(data['Courant']),sValue=sValue2)
except:
Domoticz.Log("Erreur calcul Courant")
Code : Tout sélectionner
dat0 = datetime.strptime(ix0[0], '%Y-%m-%dT%H:%M:%S')
Code : Tout sélectionner
try:
dat0 = datetime.strptime(ix0[0], '%Y-%m-%dT%H:%M:%S')
except TypeError:
dat0 = datetime.fromtimestamp(time.mktime(time.strptime(ix0[0], '%Y-%m-%dT%H:%M:%S')))
J'avoue être très intéressé par les fonctionnalité du module D2L, à condition de pouvoir aller au delà de la simple récupération de l'intensité et du calcul de la puissance.Il est préférable de ne maintenir qu'un seul plugin.
Pour l'évolution de celui-existant, je vous laisse contacter son auteur via le forum, il sera ravi d'échanger avec vous.
Si vous m'y autorisez, je peux lui transmettre vos coordonnées.
Cordialement,
Alain, Support eeSmart
Mon identifiant n'a pas changé, le mot de passe non plus.{'status': 2
'version': '1.0.3'
'erreur': 'Identifiants incorrects'}