Plugin Python :how update SignalLevel and BatteryLevel (and custumImage)
Posted: Tuesday 21 March 2017 11:19
Hi everybody!!
For a plugin, i need to update the BatteryLevel to devices in domoticz
To do it, i have update the UpdateDevice code like that :
before :
after :
As you can see, i also update the CustumImage attribut, but i didn't find how to get it back from domoticz's DB, so i can't check if the value have change
If anyone know how to get it ...
thk's
For a plugin, i need to update the BatteryLevel to devices in domoticz
To do it, i have update the UpdateDevice code like that :
before :
Code: Select all
def UpdateDevice(Unit, nValue, sValue):
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
if (Unit in Devices):
if (Devices[Unit].nValue != nValue) or (Devices[Unit].sValue != sValue):
Devices[Unit].Update(nValue, str(sValue))
Domoticz.Log("Update "+str(nValue)+":'"+str(sValue)+"' ("+Devices[Unit].Name+")")
return
Code: Select all
def UpdateDeviceWithBattery(Unit, nValue, sValue, CustomImage, SignalLevel, BatteryLevel):
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
if (Unit in Devices):
if (Devices[Unit].nValue != nValue) or (Devices[Unit].sValue != sValue) or (Devices[Unit].SignalLevel != SignalLevel) or (Devices[Unit].BatteryLevel != BatteryLevel) :
Devices[Unit].Update(nValue, str(sValue),CustomImage, SignalLevel, BatteryLevel)
Domoticz.Log("Update "+str(nValue)+":'"+str(sValue)+"' SignalLevel:"+str(SignalLevel)+" batteryLevel:'"+str(BatteryLevel)+"%' ("+Devices[Unit].Name+")")
return

If anyone know how to get it ...
thk's