BUG ! Computed kWh device cannot be updated with initial svalue (workaround found)
Posted: Wednesday 25 June 2025 9:35
Below is a small piece of code from a Python Plugin that I am developing using the DomoticzEx framework.
After each piece of code I have pasted the log output. It all seems to work fine except for the final update.
You can see the sValue is not updated onto the device. sValue remains ''" instead of "7;1". Why?
I do not understand why the last update does not work. Someone here does?
The device is a kWh device with the kWh value to be computed from the Watts input (not from device). I have checked the definition of the device and that shows up correctly. According to the Wiki the nValue should be zero and the sValue should be in the format "123;123456" and the second value will be ignored.
After each piece of code I have pasted the log output. It all seems to work fine except for the final update.
You can see the sValue is not updated onto the device. sValue remains ''" instead of "7;1". Why?
I do not understand why the last update does not work. Someone here does?
The device is a kWh device with the kWh value to be computed from the Watts input (not from device). I have checked the definition of the device and that shows up correctly. According to the Wiki the nValue should be zero and the sValue should be in the format "123;123456" and the second value will be ignored.
Code: Select all
Unit=DEVSLIST[Dev][0]
DeviceID="{:04x}{:04x}".format(self.Hwid,Unit)
Domoticz.Log(responseJson["stats"][Dev])
output is: 2025-06-25 09:22:28.900 Xtend: 7
fieldValue=responseJson["stats"][Dev]
Domoticz.Log(Devices[DeviceID].Units[Unit])
output is: 2025-06-25 09:22:28.900 Xtend: Unit: 43, Name: 'XTEND: HP energy usage', nValue: 7, sValue: '', LastUpdate: 2025-06-25 09:21:17
Devices[DeviceID].Units[Unit].nValue=0
Devices[DeviceID].Units[Unit].sValue=str(fieldValue)+";1" # watts are supplied, kwh are calculated by Domoticz.
Domoticz.Log(Devices[DeviceID].Units[Unit].sValue)
output is: 2025-06-25 09:22:28.900 Xtend: 7;1
Devices[DeviceID].Units[Unit].Update()
Domoticz.Log(Devices[DeviceID].Units[Unit])
output is: 2025-06-25 09:22:28.914 Xtend: Unit: 43, Name: 'XTEND: HP energy usage', nValue: 0, sValue: '', LastUpdate: 2025-06-25 09:22:28