how to copy data from watermeter to waterflow  [Solved]

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

Moderator: leecollings

Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

how to copy data from watermeter to waterflow  [Solved]

Post by Gravityz »

Hello,

i have a virtual watermeter(counter incremental) which receives the liters used.
it does so on a 60 second base.

now i want to copy what is send to the watermeter also to the waterflow(virtual device) to get the amount of liters/minute.

should be straight forward but i can not get this to work.

i either need what was send to the watermeter also send to the waterflow
or

watermeter-current-value minus watermeter-previous-value send to waterflow.
using the watermeter as a trigger device

is there an easy way to do this?
It can be done by using json but it seems a bit as a workaround(use json to update the weaterflow)

also does this command domoticz.device(' waterflow' ).update(liters) exist.

i know there are a lot of update features but they are not available on a flow device, only on temp and barometer or energy devices


thanks
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by waaren »

Gravityz wrote: Thursday 16 January 2020 15:14 should be straight forward but i can not get this to work.
Could look like below
i know there are a lot of update features but they are not available on a flow device, only on temp and barometer or energy devices
dzVents has a native method WaterflowUpdate for this since version 2.1 (domoticz V3.8088)

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            'waterMeter',  -- change to name of your watermeter
        },
    },
    data = 
    {
        water = 
        { 
            initial = {},
        },
    },

    execute = function(dz, item)
        local factor = 1          -- this might need to be changed depending on if your meter is in liters or m3 or different. 
        local waterFlow = dz.devices('waterFlow')
        local waterTotal = tonumber(item.sValue) * factor -- watermeter can be of type counter or custom sensor sValue works for both

        if dz.data.water.total ~= nil then  -- first reading does not update the flowmeter 
            waterFlow.cancelQueuedCommands()
            local pastTime = dz.data.water.lastTime - dz.time.dDate -- seconds since last time
            local waterFlowValue = ( waterTotal - dz.data.water.total ) * 60 / math.max(pastTime,60)  -- liter / min
            waterFlow.updateWaterflow(waterFlowValue)
            waterFlow.updateWaterflow(0).afterSec(60)  -- if no new data within 60 seconds the reset flow to 0
        end

        dz.data.water.total = waterTotal 
        dz.data.water.lastTime = dz.time.dDate

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by Gravityz »

hmm.

getting this error

lua:27: attempt to index a number value (local 'waterFlow')

line 27 is waterFlow.updateWaterflow(waterFlow)


i named my flow meter waterFlow like in the script.

could it be that the local name being the same as the device name is causing this?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by waaren »

Gravityz wrote: Friday 17 January 2020 18:43 line 27 is waterFlow.updateWaterflow(waterFlow)
Can you change line 26/27 to

Code: Select all

            local waterFlowValue = ( waterTotal - dz.data.water.total ) * 60 / math.max(pastTime,60)  -- liter / min
            waterFlow.updateWaterflow(waterFlowValue)
and try again
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by Gravityz »

ok tried again but the waterflow meter (named Flow) updates with a value of 446464

UPDATE
found the problem
my watermeter is an incremental counter so i needed to use .counterToday
Thanks Waaren for the help

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            'Watermeter',  -- change to name of your watermeter
        },
    },
    data = 
    {
        water = 
        { 
            initial = {},
        },
    },

    execute = function(dz, item)
        local factor = 1          -- this might need to be changed depending on if your meter is in liters or m3 or different. 
        local waterFlow = dz.devices('Flow')
       local waterTotal = item.counterToday * factor -- watermeter can be of type counter or custom sensor sValue works for both
       

        if dz.data.water.total ~= nil then  -- first reading does not update the flowmeter 
            waterFlow.cancelQueuedCommands()
            local pastTime = dz.data.water.lastTime - dz.time.dDate -- seconds since last time
            local waterFlowValue = ( waterTotal - dz.data.water.total ) * 60 / math.max(pastTime,60)  -- liter / min

            waterFlow.updateWaterflow(waterFlowValue)
            waterFlow.updateWaterflow(0).afterSec(5)  -- if no new data within 60 seconds the reset flow to 0
        end

        dz.data.water.total = waterTotal 
        dz.data.water.lastTime = dz.time.dDate

    end
}
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by Gravityz »

@waaren, can you look at this script.

i modified it so i can calculate a more accurate flow
the watermeter now gets updated instantly

i then calculate the time between 2 updates to calculate the flow.
It seems to work allright but the flow fluctuates a bit and i am not sure i did calculate things right.
i

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            'Watermeter',  -- change to name of your watermeter
        },
    },
    data = 
    {
        water = 
        { 
            initial = {},
        },
    },

    execute = function(dz, item)
        local Time = require('Time')
        local currentTime = Time()
        local factor = 1000          -- this might need to be changed depending on if your meter is in liters or m3 or different. 
        local waterFlow = dz.devices('Flow')
        local waterTotal = item.counterToday * factor -- watermeter can be of type counter or custom sensor sValue works for both
 
        if dz.data.water.total ~= waterTotal then  -- first reading does not update the flowmeter 
            waterFlow.cancelQueuedCommands()
            local pasttime = (currentTime.compare(dz.data.water.lastTime).milliseconds)
                        local waterFlowValue = 60000 / pasttime
                        waterFlowValue = dz.round(waterFlowValue,2)
            waterFlow.updateWaterflow(waterFlowValue)
            waterFlow.updateWaterflow(0).afterSec(60)  -- if no new data within 60 seconds then reset flow to 0
        end

        dz.data.water.total = waterTotal 
        dz.data.water.lastTime = currentTime

    end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by waaren »

Gravityz wrote: Wednesday 22 January 2020 21:02 i modified it so i can calculate a more accurate flow. The watermeter now gets updated instantly
In terms of script-logic I don't see a problem but you assume here an accuracy that is simply not there.
The watermeter total is not updated every second let alone milliseconds and even if that would be the case, the performance optimized way dzVents and Lua bundles information from all devices to be processed in the scripts causes the real time data to be off by sometimes more then a second.

So for the sake of understanding the process it's ok but please don't take it to serious. :)

Another thing to consider here is that you now write the complete dzVents time object as a table to persistent data.
This will write 189 lines 4150 bytes to disk every run. In the original script it was 7 lines / 150 bytes
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by Gravityz »

Yes i know accuracy is off but in the old situation it was even worse.

old situation Watermeter update once every 60 seconds: resolution 1 liter
new situation Watermeter updates with usage of every liter :resolution better than 1 liter(but it still fluctuates with a delta of 2 liters)

is there anything i can do to avoid flooding memory and still get a little better accuray than 1 liter or 1 second?

if not i might go back to the old situation.

i like it that the Watermaeter changes instantly on usage but the flow functionality is not more accurate, just faster in updating the real flow
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by waaren »

Gravityz wrote: Thursday 23 January 2020 8:29 is there anything i can do to avoid flooding memory and still get a little better accuray than 1 liter or 1 second?
Not with domoticz.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by Gravityz »

ok, clear.

i however noticed that the compare function can be used to compare on a millisecond level but the outcome is still on a second resolution base

Code: Select all

 local pastTime = tonumber (t.compare(dz.data.water.lastTime).ms)
eg it is comparing 2 times but the difference is not measured in milliseconds but in seconds/1000
This is the reason i still get 8,57L or 10 liter as outcome

i noticed that when you use data with history is true you can compare 2 timestamps and get the difference in milliseconds by using the msAgo option.
Tried something but i lack the knowlegde

if this works on the current data we can get low memory usage and still get better resolution
The only thing i want is something more accurate than 1 liter or 1 second

eg 8,57 or 10 liter means the real usage is probably more towards the 10 liter but missing 1 pulse drops the outcome to 8,57
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by bertbigb »

Hello all,

I have try to use the script but I run into problems, I can't get it to work.
From what I found the value dz.data.water.total always stays nil

2021-01-28 17:55:46.718 Status: dzVents: Info: Handling events for: "Watermeter", value: "18446744073709453933"
2021-01-28 17:55:46.718 Status: dzVents: Info: ------ Start internal script: Waterflow-1-1: Device: "Watermeter (Dummy)", Index: 141
2021-01-28 17:55:46.718 Status: dzVents: Info: ------ Finished Waterflow-1-1
2021-01-28 17:55:46.718 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Waterflow-1-1
2021-01-28 17:55:46.718 Error: dzVents: Error: (3.0.2) ...ticz/scripts/dzVents/generated_scripts/Waterflow-1-1.lua:21: attempt to concatenate a nil value (field 'total')

Code: Select all

return 
{
    on = 
    { 
        devices = 
        {
            'Watermeter', -- change to name of your watermeter
        },
    },

    data =
    {
        water =
        {
            initial = { 0 },
        },
    },
 
    execute = function(dz, item) 

        dz.log (' waterTotal= ' .. dz.data.water.total, dz.LOG_FORCE)

        if dz.data.water.total ~= nil then -- first reading does not update the flowmeter
            local pastTime = dz.time.dDate - dz.data.water.lastTime -- seconds since last time
            if pastTime > 55 then 
                local factor = 1 -- this might need to be changed depending on if your meter is in liters or m3 or different.
                local waterFlow = dz.devices('Waterflow')
                
                local waterTotal = item.counterToday * factor -- watermeter can be of type counter or custom sensor sValue works for both
                dz.log (' waterTotal= ' .. waterTotal, dz.LOG_FORCE)
        
                local waterFlowValue = dz.utils.round((( waterTotal - dz.data.water.total ) * 60) / pastTime, 2) -- liter / min
                dz.log (' waterFlowValue= ' .. waterFlowValue, dz.LOG_FORCE)
                if waterFlowValue > 0 then 
                    waterFlow.cancelQueuedCommands()
                    waterFlow.updateWaterflow(waterFlowValue)
                    waterFlow.updateWaterflow(0).afterSec(70) -- if no new data within 60 seconds the reset flow to 0    
                end
                dz.data.water.total = waterTotal
                dz.data.water.lastTime = dz.time.dDate
            end
        end
    end
}
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by Gravityz »

the Watermeter in my situation is a dummy counter(not incremental)
after that i have set it to water.
so it is not a waterflow device

i do not use this script anymore
i use the esp to give me both the counter and waterflow(in 0,1 liter)

so basically the esp holds the complete countertotal and sends that value to domoticz
this way i always get the correct value

the same goes for waterflow.
it turns out the esp pulsecounter sends out a time between pulss in ms. i use this number to calculate the exact flow and send this value over to domoticz.

so not more problems regarding timing and fast/slow calls
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by waaren »

bertbigb wrote: Thursday 28 January 2021 17:57 I have try to use the script but I run into problems, I can't get it to work.
From what I found the value dz.data.water.total always stays nil
The changes made to the script is causing it to fail and that 's why the persistent data is not set / updated ever.

Can you try with this one?

Code: Select all

return 
{
    on = 
    { 
        devices = 
        {
            'Watermeter', -- change to name of your watermeter
        },
    },

    data =
    {
        water =
        {
            initial = { },
        },
    },
 
    execute = function(dz, item) 

        dz.log (' waterTotal= ' .. ( dz.data.water.total or 'not set yet'), dz.LOG_FORCE)

        if dz.data.water.total ~= nil then -- first reading does not update the flowmeter
            dz.data.water.lastTime = dz.data.water.lastTime or os.time()
            local pastTime = os.time() - dz.data.water.lastTime  -- seconds since last time
            if pastTime > 55 then 
                local factor = 1 -- this might need to be changed depending on if your meter is in liters or m3 or different.
                local waterFlow = dz.devices('Waterflow')
                
                local waterTotal = item.counterToday * factor -- watermeter can be of type counter or custom sensor sValue works for both
                dz.log (' waterTotal= ' .. waterTotal, dz.LOG_FORCE)
        
                local waterFlowValue = dz.utils.round((( waterTotal - dz.data.water.total ) * 60) / pastTime, 2) -- liter / min
                dz.log (' waterFlowValue= ' .. waterFlowValue, dz.LOG_FORCE)
                if waterFlowValue > 0 then 
                    waterFlow.cancelQueuedCommands()
                    waterFlow.updateWaterflow(waterFlowValue)
                    waterFlow.updateWaterflow(0).afterSec(70) -- if no new data within 60 seconds the reset flow to 0    
                end
                dz.data.water.total = waterTotal
                dz.data.water.lastTime = os.time()
            end
        else
            dz.data.water.total = 0
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by bertbigb »

Hi,
I tried the new code and this is what it is telling me.
Spoiler: show

Code: Select all

2021-01-28 21:51:31.968 Status: dzVents: Info: Handling events for: "Watermeter", value: "18446744073709453931"
2021-01-28 21:51:31.968 Status: dzVents: Info: ------ Start internal script: Waterflow-1-1: Device: "Watermeter (Dummy)", Index: 141
2021-01-28 21:51:31.968 Status: dzVents: !Info: waterTotal= not set yet
2021-01-28 21:51:31.969 Status: dzVents: Info: ------ Finished Waterflow-1-1
2021-01-28 21:52:02.153 Status: dzVents: Info: Handling events for: "Watermeter", value: "18446744073709453932"
2021-01-28 21:52:02.154 Status: dzVents: Info: ------ Start internal script: Waterflow-1-1: Device: "Watermeter (Dummy)", Index: 141
2021-01-28 21:52:02.154 Status: dzVents: !Info: waterTotal= not set yet
2021-01-28 21:52:02.154 Status: dzVents: Info: ------ Finished Waterflow-1-1
2021-01-28 21:52:32.107 Status: dzVents: Info: Handling events for: "Watermeter", value: "18446744073709453934"
2021-01-28 21:52:32.107 Status: dzVents: Info: ------ Start internal script: Waterflow-1-1: Device: "Watermeter (Dummy)", Index: 141
2021-01-28 21:52:32.108 Status: dzVents: !Info: waterTotal= not set yet
2021-01-28 21:52:32.108 Status: dzVents: Info: ------ Finished Waterflow-1-1
Here you see that the value goes up (I used water) but there is no value displayed. waterTotal stays as waterTotal= not set yet


I hope you can help me a bit with this.
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by waaren »

bertbigb wrote: Thursday 28 January 2021 21:56 I tried the new code and this is what it is telling me.
I hope you can help me a bit with this.
Sure,

I updated my earlier posted version (the one at 20:00 hr.) It should now only give this message once.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by bertbigb »

Hi Waaren,

Indeed the new code prevented only gives the message once.
But now i'm running into new problems. The lastTime variable is nil.

Spoiler: show

Code: Select all

2021-01-29 11:12:20.906 Status: dzVents: Info: Handling events for: "Watermeter", value: "18446744073709453685"
2021-01-29 11:12:20.906 Status: dzVents: Info: ------ Start internal script: Waterflow-1-1: Device: "Watermeter (Dummy)", Index: 141
2021-01-29 11:12:20.907 Status: dzVents: !Info: waterTotal= 0
2021-01-29 11:12:20.907 Status: dzVents: Info: ------ Finished Waterflow-1-1
2021-01-29 11:12:20.907 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Waterflow-1-1
2021-01-29 11:12:20.907 Error: dzVents: Error: (3.0.2) ...ticz/scripts/dzVents/generated_scripts/Waterflow-1-1.lua:24: attempt to perform arithmetic on a nil value (field 'lastTime')
2021-01-29 11:12:50.922 Status: dzVents: Info: Handling events for: "Watermeter", value: "18446744073709453688"
2021-01-29 11:12:50.923 Status: dzVents: Info: ------ Start internal script: Waterflow-1-1: Device: "Watermeter (Dummy)", Index: 141
2021-01-29 11:12:50.923 Status: dzVents: !Info: waterTotal= 0
2021-01-29 11:12:50.923 Status: dzVents: Info: ------ Finished Waterflow-1-1
2021-01-29 11:12:50.923 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Waterflow-1-1
2021-01-29 11:12:50.923 Error: dzVents: Error: (3.0.2) ...ticz/scripts/dzVents/generated_scripts/Waterflow-1-1.lua:24: attempt to perform arithmetic on a nil value (field 'lastTime')
2021-01-29 11:13:21.009 Status: dzVents: Info: Handling events for: "Watermeter", value: "18446744073709453688"
2021-01-29 11:13:21.009 Status: dzVents: Info: ------ Start internal script: Waterflow-1-1: Device: "Watermeter (Dummy)", Index: 141
2021-01-29 11:13:21.010 Status: dzVents: !Info: waterTotal= 0
2021-01-29 11:13:21.010 Status: dzVents: Info: ------ Finished Waterflow-1-1
2021-01-29 11:13:21.010 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Waterflow-1-1
2021-01-29 11:13:21.010 Error: dzVents: Error: (3.0.2) ...ticz/scripts/dzVents/generated_scripts/Waterflow-1-1.lua:24: attempt to perform arithmetic on a nil value (field 'lastTime')
Can you please help me to get this solved also?
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by waaren »

bertbigb wrote: Friday 29 January 2021 11:17 Indeed the new code prevented only gives the message once.
But now i'm running into new problems. The lastTime variable is nil. Can you please help me to get this solved also?
Sure,

This type of errors occur usually because a variable is not initialized yet. That's also why you get this error here.
It should be solved by below line where the value of dz.data.water.lastTime is initialized with current time (in seconds from 1/1/1970) when stil nil

Code: Select all

dz.data.water.lastTime = dz.data.water.lastTime or os.time()
I updated my earlier posted version again.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: how to copy data from watermeter to waterflow

Post by bertbigb »

Thanks once more, now I'm getting values in.
Many thanks for your quick replies and your great help.!
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
Hansbit
Posts: 36
Joined: Monday 17 February 2014 15:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: how to copy data from watermeter to waterflow

Post by Hansbit »

I think you could better use

Code: Select all

item.counter
instead of

Code: Select all

item.counterToday
because value is calculated relative to previous value. No difference in displayed flow value, but counterToday is daily set to 0 at nighttime and results in a negative flow.
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: how to copy data from watermeter to waterflow

Post by Number8 »

Gravityz wrote: Thursday 28 January 2021 18:20 the Watermeter in my situation is a dummy counter(not incremental)
after that i have set it to water.
so it is not a waterflow device

i do not use this script anymore
i use the esp to give me both the counter and waterflow(in 0,1 liter)

so basically the esp holds the complete countertotal and sends that value to domoticz
this way i always get the correct value

the same goes for waterflow.
it turns out the esp pulsecounter sends out a time between pulss in ms. i use this number to calculate the exact flow and send this value over to domoticz.

so not more problems regarding timing and fast/slow calls
Hello, I hope you are still monitoring this thread. Could elaborate on your esp setup? What esp are you using, etc. Thank you
Debian buster on NUC and three RPi with buster.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest