DzVents Script reports sometimes a wrong value

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

Hello,
I have a problem with a dzVents script.
Version: 2024.7 Build 16355
Platform: Raspi 3B, Raspbian 11 (bullseye) run on a SSD
In about 3% of all script runs, wrong values will sent to my Ulanzi TC001 pixel display. Other values (temperatures, PV power, grid power,...) are correct, only the battery SOC makes a problem:
My PV batterie reports every 5 minutes the SOC to a domoticz sensor:

Code: Select all

url = 'http://10.0.0.142:8080/json.htm?type=command&param=udevice&idx=35&nvalue=0&svalue={:d}'.format(SOC_result)
This work 100% correct.

This dzVents script gives in about 3% of all runs a incorrect value:

Code: Select all

return {
    on = { 
        devices = {'Batterie_SOC'}, 
        timer = { 'every 1 minutes' } 
        },
    execute = function(domoticz, device)
    BAT = domoticz.devices('Batterie_SOC').percentage;
    print ("Batt SOC " .. BAT .. '%')
    domoticz.openURL({
        url = 'http://10.0.0.157/api/custom?name=SOC',
        method = 'POST',
        callback = 'SOC',
        postData = {
            text = BAT .. '%',
            color = '#EBEAFF',
            icon = 6354,
            lifetime = 300
        }
    })
    end
}
For example:
Domoticz sensor "Batterie_SOC" is now 12%
But it reports 16%:
2025-01-26 07:46:06.297 dzVents: ------ Start internal script: AwtrixSOC:, trigger: "every 1 minutes"
2025-01-26 07:46:06.298 dzVents: Batt SOC 16%
the next run is correct:
2025-01-26 07:48:30.810 dzVents: ------ Start internal script: AwtrixSOC:, trigger: "every 1 minutes"
2025-01-26 07:48:30.811 dzVents: Batt SOC 12%

Maybe you have a idea to this issue?
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
waltervl
Posts: 5906
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by waltervl »

Perhaps use
local BAT =
This to be sure it does not get mixed up with another BAT value.

And you update every 5 minutes from the batterie but sends it to display every minutes.
It could be it is a timing issue as the updates from batterie is just milliseconds after the sending to display.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

Thank you, will try "local BAT=..."
This is definitly no timing issue: Batterie_SOC is 10% for hours, because this is the end-SOC of discharging. The script sends almost every time 10% to the pixel display, and then once for example 62%.
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by habahabahaba »

viewtopic.php?p=322121#p322121

Post data have to be all string format
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

Thank you for your tips, but the problem still exists :-(
current script is:

Code: Select all

return {
    on = { 
        devices = {'Batterie_SOC'}, 
        timer = { 'every 1 minutes' } 
        },
    execute = function(domoticz, device)    
    local BAT = domoticz.devices('Batterie_SOC').percentage;    
    print ("Batt SOC " .. tostring(BAT) .. '%')
    domoticz.openURL({        
        url = 'http://10.0.0.157/api/custom?name=SOC',
        method = 'POST',
        callback = 'SOC',
        postData = {
            text = tostring(BAT) .. '%',
            color = '#EBEAFF',
            icon = '6354',
            lifetime = '300'
        }
    })    
    end
}
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
waltervl
Posts: 5906
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by waltervl »

And there is only 1 device named Batterie_SOC?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

Yes, only one
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by habahabahaba »

What is the type of device Batterie_SOC?
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

General/Percentage
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by habahabahaba »

mgerhard74 wrote: Wednesday 29 January 2025 7:09 General/Percentage
How and how often is it updated?
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

Every 5 minutes
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by habahabahaba »

No idea...

So if it is not timing issue and it is battery device... may be problem is in device? Or plugin (if it is zigbee device)?
lost
Posts: 663
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by lost »

mgerhard74 wrote: Sunday 26 January 2025 8:08 In about 3% of all script runs, wrong values
(...)
My PV batterie reports every 5 minutes the SOC to a domoticz sensor:

Code: Select all

return {
    on = { 
        devices = {'Batterie_SOC'}, 
        timer = { 'every 1 minutes' } 
        },
(...)
For example:
Domoticz sensor "Batterie_SOC" is now 12%
But it reports 16%:
2025-01-26 07:46:06.297 dzVents: ------ Start internal script: AwtrixSOC:, trigger: "every 1 minutes"
2025-01-26 07:46:06.298 dzVents: Batt SOC 16%
the next run is correct:
2025-01-26 07:48:30.810 dzVents: ------ Start internal script: AwtrixSOC:, trigger: "every 1 minutes"
2025-01-26 07:48:30.811 dzVents: Batt SOC 12%

Maybe you have a idea to this issue?
1st observation is when reading is correct, for a script supposed to trigger on 1 minute (almost exact) boundaries, request time looks to be 6s from your example time log... and 30s when result is incorrect? Not using dzVent but my Lua time scripts tiggers very shortly after HH:MM:00 and this already looks suspicious for me.

+ you read every minute for a data updated by your hardware every 5mn.

So, if valid update delay is correct, 6s for a correctly handled request on a 1 minute time slice for a data updated every 5mn gives a probability to have the request from Domoticz done during data update by HW of (6/60)*1/5, so roughly your 3% fails figure.

For hand done request that succeeds, do you observe such long response times?
User avatar
waltervl
Posts: 5906
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by waltervl »

You could try to leave out the 1 minute timer trigger.
Then when the Domoticz device 'Batterie_SOC' is updated (by another script or plugin), it will immediately be sent to the display. I see no need to send the data to the display every minute....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by habahabahaba »

lost wrote: Wednesday 29 January 2025 9:17 Domoticz done during data update by HW of (6/60)*1/5, so roughly your 3% fails figure.
How did you count that?? :shock:

Batterie_SOC updates every 5 mn so it was updated at 07:45:00
AwtrixSOC runs every 1 mn so it started at 07:46:00 (07:46:06 from log) - after ONE minute when Batterie_SOC have to be in the right value.

But i agree that the script running delay is too big.

maybe the system is overloaded with something?
then it could cause time overlaps.
lost
Posts: 663
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by lost »

Did not saw any indication that updates were in sync exactly every 5mn. So I believed reads were asynchronous vs updates so that's just based on a sliding 1mn (60s) window that may fall on a 6s data read time over 5x1mn slices (HW update time).

My guess was reading exactly when, unfortunately, an update was done by HW may cause bad readings from Domoticz.

But I may be wrong, I don't own this hardware...
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

Thank you waltervl , i will try this:
waltervl wrote: Wednesday 29 January 2025 9:57 You could try to leave out the 1 minute timer trigger.
Then when the Domoticz device 'Batterie_SOC' is updated (by another script or plugin), it will immediately be sent to the display. I see no need to send the data to the display every minute....
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
mgerhard74
Posts: 48
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by mgerhard74 »

Can anyone tell me why a dzVents script does not run every minute (I can see it in the log) if this is entered in the script?

Code: Select all

timer = { 'every 1 minutes' }
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by habahabahaba »

Full code and log?
User avatar
waltervl
Posts: 5906
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DzVents Script reports sometimes a wrong value

Post by waltervl »

Try

Code: Select all

timer =  { 'every minute' }
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest