Page 1 of 1

problems with update Energy Meter

Posted: Monday 04 May 2020 0:02
by fabix68
I'm trying to update a virtual electric meter sensor with the updateElectricity (power, energy) command.
Something does not work.
The value on the energy meter is not updated correctly
What am I wrong with?

DZvents Scripts

Code: Select all

            print('Whtotal PRIMA -> '..domoticz.devices('test_meter').WhTotal)
            print('Energia  -> ' ..( energia_consumata-energia_prodotta))
            domoticz.devices('test_meter').updateElectricity(consumata_attuale,domoticz.devices('test_meter').WhTotal+(energia_consumata-energia_prodotta))
            print('Whtotal DOPO -> '..domoticz.devices('test_meter').WhTotal)
Domoticz Log

Code: Select all

2020-05-04 00:00:00.261 Status: dzVents: ++ Whtotal PRIMA -> 11222.0
2020-05-04 00:00:00.261 Status: dzVents: ++ Energia -> 6.0
2020-05-04 00:00:00.261 Status: dzVents: ++ Whtotal DOPO -> 11222.0
2020-05-04 00:01:00.350 Status: dzVents: ++ Whtotal PRIMA -> 11228.0
2020-05-04 00:01:00.350 Status: dzVents: ++ Energia -> 8.0
2020-05-04 00:01:00.351 Status: dzVents: ++ Whtotal DOPO -> 11228.0

Re: problems with update Energy Meter

Posted: Monday 04 May 2020 0:14
by waaren
fabix68 wrote: Monday 04 May 2020 0:02 I'm trying to update a virtual electric meter sensor with the updateElectricity (power, energy) command.
Something does not work.
The value on the energy meter is not updated correctly
Not sure what you expect but the update of the device will not happen until the script has finished and the updateElectricity command is processed by domoticz. This is the way it works with all dzVents and classic Lua scripts.

If something else is not working as expected please include the complete script and the log output with script debug enabled.