problems with update Energy Meter

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
fabix68
Posts: 10
Joined: Tuesday 22 December 2015 6:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

problems with update Energy Meter

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: problems with update Energy Meter

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest