Commit initial
Espace disque Infos system Présence adresse mac
This commit is contained in:
58
README.md
Normal file
58
README.md
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Domoticz Freebox Plugin
|
||||||
|
Plugin Python Domoticz pour accéder au services de l'API V4 de la Freebox
|
||||||
|
|
||||||
|
## Fonctionnalités
|
||||||
|
|
||||||
|
* Création du token d'authentification lors du premier lancement (une validation est nécessaire sur l'écran de la Freebox serveur)
|
||||||
|
* Création d'un dispositif par partition de disque dur connecté à la Freebox (disques internes et externes)
|
||||||
|
* Création de 3 dispositifs pour suivre les températures de la Freebox
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Requis : Python version 3.4 or supérieur & Domoticz version 3.87xx ou supérieur.
|
||||||
|
|
||||||
|
* En ligne de commande aller dans le répertoire plugin de Domotivz (domoticz/plugins)
|
||||||
|
* Lancer la commande: ```git clone https://github.com/supermat/XXXX.git```
|
||||||
|
* Redemmarrer le service Domoticz en lancant la commande '''sudo /init.d/domoticz restart'''
|
||||||
|
|
||||||
|
## Updating
|
||||||
|
|
||||||
|
Pour mettre à jour le plugin :
|
||||||
|
|
||||||
|
* En ligne de commande aller dans le répertoire plugin de Domotivz (domoticz/plugins)
|
||||||
|
* Lancer la commande: ```git pull```
|
||||||
|
* Redemmarrer le service Domoticz en lancant la commande ```sudo /init.d/domoticz restart```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
| Field | Information|
|
||||||
|
| ----- | ---------- |
|
||||||
|
| Address | L'adresse d'accès à la box avec le http(s) devant (http://mafreebox.free.fr sur réseau local) |
|
||||||
|
| Port | Le port pour accéder à la Freebox (80 sur réseau local) |
|
||||||
|
| Token | Le Token de connexion à la Freebox qui vous sera donné lors de la première connexion du plugin (voir les log) |
|
||||||
|
| Debug | Si true plus de log apparaitront dans la console de log |
|
||||||
|
|
||||||
|
Dans la partie Matériel de Domoticz, chercher 'Freebox Python Plugin'.
|
||||||
|
Laissez les valeur par defaut sur un réseau local, ou configurez votre adresse et port.
|
||||||
|
Ajoutez le Matériel et rendez vous dans les log.
|
||||||
|
Lors de la première utilisation, laissez le token vide.
|
||||||
|
|
||||||
|
Au démarrage, si le token n'est pas défini, le plugin en demander un à la Freebox, il vous faut alors vous déplacer jusqu'à l'écran de la Freebox pourrépondre oui, puis revenir sur votre Domoticz pour copier coller le token qui s'affiche dans la fenetre de log, dans la partie Token de confirguration du plugin.
|
||||||
|
|
||||||
|
Desactivez le plugin, autoriser l'ajout de nouveau dispositif pendant 5 minutes, puis réacivez le plugin pour le faire redemarrer.
|
||||||
|
Les dispositifs vont se créer.
|
||||||
|
A chaque démarrage du plugin, les dispositifs nouveaux ou maquant seront ajoutés.
|
||||||
|
Vous pouvez supprimer ceux qui ne vous interresse pas et inclure ceux qui vous interresse.
|
||||||
|
|
||||||
|
| Dispositifs | Description|
|
||||||
|
| ----- | ---------- |
|
||||||
|
| Système | Températures de la Freebox et du switch interne |
|
||||||
|
| Disque | Pourcentage d'espace utilisé de chaque partition connectées à la Freebox au moment du démarrage du Plugin avec autorisation d'ajout de dispositifs |
|
||||||
|
|
||||||
|
Note : Un fichier ```devicemapping.json``` est créé pour garder l'association des infos de la Freebox avec le bon device créé au moment du démarrage du Plugin.
|
||||||
|
|
||||||
|
## Change log
|
||||||
|
|
||||||
|
| Version | Information|
|
||||||
|
| ----- | ---------- |
|
||||||
|
| 1.0 | Version initial : connexion (token), températures système, espace disque |
|
||||||
119
freebox.py
Normal file
119
freebox.py
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
#Code adapté de http://www.manatlan.com/blog/freeboxv6_api_v3_avec_python
|
||||||
|
|
||||||
|
import urllib.request,hmac,json,hashlib,time
|
||||||
|
from urllib.request import urlopen,Request
|
||||||
|
|
||||||
|
class FbxCnx:
|
||||||
|
def __init__(self,host="mafreebox.free.fr"):
|
||||||
|
self.host=host
|
||||||
|
|
||||||
|
def register(self,appid,appname,version,devname):
|
||||||
|
data={'app_id': appid,'app_name': appname,'app_version':version,'device_name': devname}
|
||||||
|
result=self._com("login/authorize/",data)
|
||||||
|
if not result["success"]:
|
||||||
|
return "Erreur Reponse Freebox : " + result["msg"]
|
||||||
|
r=result["result"]
|
||||||
|
trackid,token=r["track_id"],r["app_token"]
|
||||||
|
s="pending"
|
||||||
|
nbWait = 0
|
||||||
|
while s=="pending":
|
||||||
|
s=self._com("login/authorize/%s"%trackid)
|
||||||
|
s = s["result"]["status"]
|
||||||
|
time.sleep(1)
|
||||||
|
nbWait = nbWait + 1
|
||||||
|
if nbWait > 30:
|
||||||
|
s = "TropLong"
|
||||||
|
return s=="granted" and token
|
||||||
|
|
||||||
|
def _com(self,method,data=None,headers=None):
|
||||||
|
url = self.host+"/api/v4/"+method
|
||||||
|
if data:
|
||||||
|
data = json.dumps(data) #On transforme en string le dict
|
||||||
|
data = data.encode() #On transforme en tableau de byte le string pour Request
|
||||||
|
request = Request(url, data=data)
|
||||||
|
request.get_method = lambda:"POST"
|
||||||
|
else:
|
||||||
|
if headers:
|
||||||
|
request = Request(url,headers=headers)
|
||||||
|
else:
|
||||||
|
request = Request(url)
|
||||||
|
res = urlopen(request).read()
|
||||||
|
return json.loads(res.decode())
|
||||||
|
|
||||||
|
def _mksession(self):
|
||||||
|
challenge=self._com("login/")["result"]["challenge"]
|
||||||
|
data={
|
||||||
|
"app_id": self.appid,
|
||||||
|
"password": hmac.new(self.token.encode(),challenge.encode(),hashlib.sha1).hexdigest()
|
||||||
|
}
|
||||||
|
return self._com("login/session/",data)["result"]["session_token"]
|
||||||
|
|
||||||
|
# def _disconnect(self):
|
||||||
|
# result = self._com("/login/logout",None,{"X-Fbx-App-Auth": self.session})
|
||||||
|
# print (result)
|
||||||
|
# return
|
||||||
|
|
||||||
|
class FbxApp(FbxCnx):
|
||||||
|
def __init__(self,appid,token,session=None,host="mafreebox.free.fr"):
|
||||||
|
FbxCnx.__init__(self,host)
|
||||||
|
self.appid,self.token=appid,token
|
||||||
|
self.session=session if session else self._mksession()
|
||||||
|
|
||||||
|
# def __del__(self):
|
||||||
|
# self._disconnect()
|
||||||
|
# print ('died')
|
||||||
|
|
||||||
|
def com(self,method,data=None):
|
||||||
|
return self._com(method,data,{"X-Fbx-App-Auth": self.session})
|
||||||
|
|
||||||
|
|
||||||
|
def diskinfo(self):
|
||||||
|
listDisk = self.com( "storage/disk/")
|
||||||
|
retour = {}
|
||||||
|
for disk in listDisk["result"]:
|
||||||
|
for partition in disk["partitions"]:
|
||||||
|
label = partition["label"]
|
||||||
|
used =partition["used_bytes"]
|
||||||
|
total=partition["total_bytes"]
|
||||||
|
percent = used/total*100
|
||||||
|
# print(str(label)+"=>"+str(round(percent,2))+"%")
|
||||||
|
retour.update({str(label):str(round(percent,2))})
|
||||||
|
return retour
|
||||||
|
|
||||||
|
def getNameByMacAdresse(self,p_macAdresse):
|
||||||
|
listePeriph = self.com( "lan/browser/pub/")
|
||||||
|
for periph in listePeriph["result"]:
|
||||||
|
macAdresse = periph["id"]
|
||||||
|
if(("ether-"+p_macAdresse) == macAdresse):
|
||||||
|
return periph["primary_name"]
|
||||||
|
|
||||||
|
def isPresenceByMacAdresse(self,p_macAdresse):
|
||||||
|
listePeriph = self.com( "lan/browser/pub/")
|
||||||
|
for periph in listePeriph["result"]:
|
||||||
|
macAdresse = periph["id"]
|
||||||
|
if(("ether-"+p_macAdresse) == macAdresse):
|
||||||
|
reachable = periph["reachable"]
|
||||||
|
active = periph["active"]
|
||||||
|
if reachable and active:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def lanPeripherique(self):
|
||||||
|
listePeriph = self.com( "lan/browser/pub/")
|
||||||
|
retour = {}
|
||||||
|
for periph in listePeriph["result"]:
|
||||||
|
name = periph["primary_name"]
|
||||||
|
reachable = periph["reachable"]
|
||||||
|
active = periph["active"]
|
||||||
|
macAdresse = periph["id"]
|
||||||
|
if reachable and active:
|
||||||
|
retour.update({macAdresse:name})
|
||||||
|
return retour
|
||||||
|
|
||||||
|
def sysinfo(self):
|
||||||
|
sys = self.com( "system/")
|
||||||
|
retour = {}
|
||||||
|
retour.update({str('temp_cpub'):str(round(sys["result"]["temp_cpub"],2))})
|
||||||
|
retour.update({str('temp_sw'):str(round(sys["result"]["temp_sw"],2))})
|
||||||
|
retour.update({str('temp_cpum'):str(round(sys["result"]["temp_cpum"],2))})
|
||||||
|
return retour
|
||||||
263
plugin.py
Normal file
263
plugin.py
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
# Freebox Python Plugin
|
||||||
|
#
|
||||||
|
# Author: https://matdomotique.wordpress.com/
|
||||||
|
#
|
||||||
|
"""
|
||||||
|
<plugin key="Freebox" name="Freebox Python Plugin" author="supermat" version="1.0.0" wikilink="http://www.domoticz.com/wiki/plugins/plugin.html" externallink="https://matdomotique.wordpress.com/">
|
||||||
|
<params>
|
||||||
|
<param field="Address" label="URL de la Box avec http devant" width="400px" required="true" default="http://mafreebox.free.fr"/>
|
||||||
|
<param field="Port" label="Port" width="100px" required="true" default="80"/>
|
||||||
|
<param field="Mode1" label="Token" width="600px"/>
|
||||||
|
<param field="Mode2" label="Liste mac adresse pour présence (séparé par ;)" width="600px"/>
|
||||||
|
<param field="Mode6" label="Debug" width="75px">
|
||||||
|
<options>
|
||||||
|
<option label="True" value="Debug"/>
|
||||||
|
<option label="False" value="Normal" default="true" />
|
||||||
|
</options>
|
||||||
|
</param>
|
||||||
|
</params>
|
||||||
|
</plugin>
|
||||||
|
"""
|
||||||
|
import Domoticz,freebox,json,os,datetime
|
||||||
|
# from data import * #Pour le debug local sinon à mettre en commentaire
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
class FreeboxPlugin:
|
||||||
|
class DeviceType(Enum):
|
||||||
|
deviceTypeDisk = 'DiskDevice'
|
||||||
|
deviceSystemInfo = 'SystemInfoDevice'
|
||||||
|
devicePresence = 'PresenceDevice'
|
||||||
|
_fileNameDeviceMapping = 'devicemapping.json'
|
||||||
|
# _deviceTypeDisk = 'DiskDevice'
|
||||||
|
# _deviceSystemInfo = 'SystemInfoDevice'
|
||||||
|
# _devicePresence = 'PresenceDevice'
|
||||||
|
enabled = False
|
||||||
|
token = ""
|
||||||
|
freeboxURL = "http://mafreebox.free.fr"
|
||||||
|
_UNIT_DISK = {}
|
||||||
|
_lastExecution = datetime.datetime.now()
|
||||||
|
def __init__(self):
|
||||||
|
#self.var = 123
|
||||||
|
return
|
||||||
|
|
||||||
|
def getDicoUnitAllDevice(self):
|
||||||
|
v_UnitKeyDico = {}
|
||||||
|
if (os.path.isfile(self._fileNameDeviceMapping)):
|
||||||
|
with open(self._fileNameDeviceMapping) as data_file:
|
||||||
|
v_UnitKeyDico = json.load(data_file)
|
||||||
|
return v_UnitKeyDico
|
||||||
|
|
||||||
|
def saveDicoUnitDevice(self, p_dicoToSave):
|
||||||
|
with open(self._fileNameDeviceMapping, 'w', encoding='utf-8') as data_file:
|
||||||
|
json.dump(p_dicoToSave, data_file)
|
||||||
|
|
||||||
|
def getNextUnsuedUnit(self,p_dicoAll):
|
||||||
|
v_count = 0
|
||||||
|
for deviceType in p_dicoAll:
|
||||||
|
v_count = v_count + len(p_dicoAll[deviceType])
|
||||||
|
return v_count+1
|
||||||
|
|
||||||
|
def getOrCreateUnitIdForDevice(self, p_deviceType, p_deviceFreeboxName):
|
||||||
|
# v_UnitKeyDico = self.getDicoUnitForDeviceType(p_deviceType)
|
||||||
|
v_dicoAll = self.getDicoUnitAllDevice()
|
||||||
|
if(p_deviceType.value in v_dicoAll):
|
||||||
|
v_dicoDeviceType = v_dicoAll[p_deviceType.value]
|
||||||
|
else:
|
||||||
|
v_dicoDeviceType = {}
|
||||||
|
v_dicoAll.update({p_deviceType.value:v_dicoDeviceType})
|
||||||
|
if(p_deviceFreeboxName in v_dicoDeviceType):
|
||||||
|
return v_dicoDeviceType[p_deviceFreeboxName]
|
||||||
|
else:
|
||||||
|
v_unit = self.getNextUnsuedUnit(v_dicoAll)
|
||||||
|
v_dicoDeviceType.update({p_deviceFreeboxName:v_unit})
|
||||||
|
self.saveDicoUnitDevice(v_dicoAll)
|
||||||
|
return v_unit
|
||||||
|
|
||||||
|
def isUnitExist(self, p_deviceType, p_deviceFreeboxName):
|
||||||
|
v_dicoAll = self.getDicoUnitAllDevice()
|
||||||
|
if(p_deviceType.value in v_dicoAll):
|
||||||
|
v_dicoDeviceType = v_dicoAll[p_deviceType.value]
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
if(p_deviceFreeboxName in v_dicoDeviceType):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def updateDeviceIfExist(self, p_deviceType, p_deviceFreeboxName, p_nValue, p_sValue):
|
||||||
|
if self.isUnitExist(p_deviceType,p_deviceFreeboxName):
|
||||||
|
v_unitKey = self.getOrCreateUnitIdForDevice(p_deviceType,p_deviceFreeboxName)
|
||||||
|
if v_unitKey in Devices:
|
||||||
|
# On ne met pas à jour un device de type devicePresence s'il est déjà à jour
|
||||||
|
if(p_deviceType.value != self.DeviceType.devicePresence.value
|
||||||
|
or (p_deviceType.value == self.DeviceType.devicePresence.value
|
||||||
|
and Devices[v_unitKey].sValue != p_sValue)
|
||||||
|
):
|
||||||
|
Devices[v_unitKey].Update(nValue=p_nValue, sValue=p_sValue)
|
||||||
|
Domoticz.Debug("Le dipositif de type "+p_deviceType.value +" associé à "+ p_deviceFreeboxName + " a été mis à jour " + str(p_nValue) + "/" + str(p_sValue))
|
||||||
|
else:
|
||||||
|
Domoticz.Debug("Le dipositif de type "+p_deviceType.value +" associé à "+ p_deviceFreeboxName + " est déjà à jour.")
|
||||||
|
else:
|
||||||
|
Domoticz.Debug("Le dipositif de type "+p_deviceType.value +" associé à "+ p_deviceFreeboxName + " a été supprimé dans Domoticz.")
|
||||||
|
else:
|
||||||
|
Domoticz.Debug("Le dipositif de type "+p_deviceType.value +" associé à "+ p_deviceFreeboxName + " n'a pas été créé dans Domoticz. Veuillez désactiver et réactiver le plugin, en autorisant l'ajout de nouveaux dispositifs.")
|
||||||
|
|
||||||
|
def onStart(self):
|
||||||
|
Domoticz.Debug("onStart called")
|
||||||
|
|
||||||
|
self.freeboxURL = Parameters["Address"]+":"+Parameters["Port"]
|
||||||
|
if Parameters["Mode6"] == "Debug":
|
||||||
|
Domoticz.Debugging(1)
|
||||||
|
DumpConfigToLog()
|
||||||
|
if Parameters["Mode1"] == "": # Le Token
|
||||||
|
Domoticz.Log("C'est votre première connexion, le token n'est pas renseigné.")
|
||||||
|
Domoticz.Log("Vous avez 30 secondes pour autoriser le plugin sur l'écran de la Freebox.")
|
||||||
|
Domoticz.Log("Une fois autorisé sur la Freebox, le token s'affichera ici.")
|
||||||
|
Token = freebox.FbxCnx(self.freeboxURL).register("idPluginDomoticz","Plugin Freebox","1","Domoticz")
|
||||||
|
if Token:
|
||||||
|
Domoticz.Log("------------------------------------------------------------------------------")
|
||||||
|
Domoticz.Log("Veuillez copier ce token dans la configuration du plugin Reglages > Matériel")
|
||||||
|
Domoticz.Log(Token)
|
||||||
|
Domoticz.Log("------------------------------------------------------------------------------")
|
||||||
|
else:
|
||||||
|
Domoticz.Log("Vous avez été trop long (ou avez refusé), veuillez désactiver et réactiver le matériel Reglages > Matériel.")
|
||||||
|
else:
|
||||||
|
self.token = Parameters["Mode1"]
|
||||||
|
Domoticz.Log("Token déjà présent. OK.")
|
||||||
|
|
||||||
|
f=freebox.FbxApp("idPluginDomoticz",self.token,host=self.freeboxURL)
|
||||||
|
usageDisk = f.diskinfo()
|
||||||
|
#Creation des device Disque Dur de la Freebox
|
||||||
|
for disk in usageDisk:
|
||||||
|
keyunit = self.getOrCreateUnitIdForDevice(self.DeviceType.deviceTypeDisk,disk)
|
||||||
|
if (keyunit not in Devices):
|
||||||
|
v_dev = Domoticz.Device(Unit=keyunit, Name="Utilisation "+disk, TypeName="Percentage")
|
||||||
|
v_dev.Create()
|
||||||
|
Domoticz.Log("Création du dispositif "+"Utilisation "+disk)
|
||||||
|
# Unfortunately the image in the Percentage device can not be changed. Use Custom device!
|
||||||
|
# Domoticz.Device(Unit=_UNIT_USAGE, Name=Parameters["Address"], TypeName="Custom", Options={"Custom": "1;%"}, Image=3, Used=1).Create()
|
||||||
|
|
||||||
|
#Creation des device infos systeme de la Freebox
|
||||||
|
sysinfo = f.sysinfo()
|
||||||
|
for info in sysinfo:
|
||||||
|
keyunit = self.getOrCreateUnitIdForDevice(self.DeviceType.deviceSystemInfo,info)
|
||||||
|
if (keyunit not in Devices):
|
||||||
|
v_dev = Domoticz.Device(Unit=keyunit, Name="System "+info, TypeName="Temperature")
|
||||||
|
v_dev.Create()
|
||||||
|
Domoticz.Log("Création du dispositif "+"System "+info)
|
||||||
|
|
||||||
|
#Creation des device presence de la Freebox
|
||||||
|
listeMacString = Parameters["Mode2"]
|
||||||
|
listeMac = listeMacString.split(";")
|
||||||
|
for macAdresse in listeMac:
|
||||||
|
name = f.getNameByMacAdresse(macAdresse)
|
||||||
|
if (name != None):
|
||||||
|
keyunit = self.getOrCreateUnitIdForDevice(self.DeviceType.devicePresence,macAdresse)
|
||||||
|
if (keyunit not in Devices):
|
||||||
|
v_dev = Domoticz.Device(Unit=keyunit, Name="Presence "+name, TypeName="Switch")
|
||||||
|
v_dev.Create()
|
||||||
|
Domoticz.Log("Création du dispositif "+"Presence "+name)
|
||||||
|
else:
|
||||||
|
Domoticz.Log("La mac adresse "+macAdresse+" est inconnu de la freebox, on ne crée aucun dispositif.")
|
||||||
|
DumpConfigToLog()
|
||||||
|
|
||||||
|
def onStop(self):
|
||||||
|
Domoticz.Log("onStop called")
|
||||||
|
|
||||||
|
def onConnect(self, Connection, Status, Description):
|
||||||
|
Domoticz.Log("onConnect called")
|
||||||
|
|
||||||
|
def onMessage(self, Connection, Data, Status, Extra):
|
||||||
|
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):
|
||||||
|
Domoticz.Debug("onHeartbeat called")
|
||||||
|
if self._lastExecution.minute == datetime.datetime.now().minute :
|
||||||
|
return
|
||||||
|
self._lastExecution = datetime.datetime.now()
|
||||||
|
if self.token == "" :
|
||||||
|
Domoticz.Log("Pas de token défini.")
|
||||||
|
return
|
||||||
|
f=freebox.FbxApp("idPluginDomoticz",self.token,host=self.freeboxURL)
|
||||||
|
|
||||||
|
usageDisk = f.diskinfo()
|
||||||
|
for disk in usageDisk:
|
||||||
|
self.updateDeviceIfExist(self.DeviceType.deviceTypeDisk,disk,int(float(usageDisk[disk])), str(usageDisk[disk]))
|
||||||
|
|
||||||
|
sysinfo = f.sysinfo()
|
||||||
|
for info in sysinfo:
|
||||||
|
self.updateDeviceIfExist(self.DeviceType.deviceSystemInfo,info,int(float(sysinfo[info])), str(sysinfo[info]))
|
||||||
|
|
||||||
|
listeMacString = Parameters["Mode2"]
|
||||||
|
listeMac = listeMacString.split(";")
|
||||||
|
for macAdresse in listeMac:
|
||||||
|
name = f.getNameByMacAdresse(macAdresse)
|
||||||
|
presence = 0
|
||||||
|
if (name != None):
|
||||||
|
if(f.isPresenceByMacAdresse(macAdresse)):
|
||||||
|
presence = 1
|
||||||
|
self.updateDeviceIfExist(self.DeviceType.devicePresence,macAdresse,presence, str(presence))
|
||||||
|
|
||||||
|
lanPeriph = f.lanPeripherique()
|
||||||
|
for periph in lanPeriph:
|
||||||
|
Domoticz.Debug(lanPeriph[periph]+" ("+periph+") présent")
|
||||||
|
|
||||||
|
global _plugin
|
||||||
|
_plugin = FreeboxPlugin()
|
||||||
|
|
||||||
|
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, Status, Extra):
|
||||||
|
global _plugin
|
||||||
|
_plugin.onMessage(Connection, Data, Status, Extra)
|
||||||
|
|
||||||
|
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.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
|
||||||
|
Domoticz.Debug("Device count: " + str(len(Devices)))
|
||||||
|
for x in Devices:
|
||||||
|
Domoticz.Debug("Device: " + str(x) + " - " + str(Devices[x]))
|
||||||
|
Domoticz.Debug("Device ID: '" + str(Devices[x].ID) + "'")
|
||||||
|
Domoticz.Debug("Device Name: '" + Devices[x].Name + "'")
|
||||||
|
Domoticz.Debug("Device nValue: " + str(Devices[x].nValue))
|
||||||
|
Domoticz.Debug("Device sValue: '" + Devices[x].sValue + "'")
|
||||||
|
Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
|
||||||
|
Domoticz.Debug("Options: '" + str(Devices[x].Options) + "'")
|
||||||
|
return
|
||||||
Reference in New Issue
Block a user