DzVents script turning on dummy switches when power use is negative

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

Moderator: leecollings

Wilpshaar
Posts: 33
Joined: Friday 08 February 2019 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Dronten, NL
Contact:

Re: DzVents script turning on dummy switches when power use is negative

Post by Wilpshaar »

Hi Patrick, got it finally work, thanks! Now very curious if it will work tomorrow with negative values, because, If I am right that did not work in blockly. Logfile latest minutes:

2022-09-21 19:07:00.627 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 420
2022-09-21 19:07:00.627 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-21 19:07:00.627 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-21 19:07:00.627 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On > 250W
2022-09-21 19:07:00.627 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 Off < 500W

2022-09-21 19:11:00.209 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 2730
2022-09-21 19:11:00.209 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-21 19:11:00.209 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : On
2022-09-21 19:11:00.209 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On > 250W
2022-09-21 19:11:00.209 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 On > 500W

Code: Select all

local scriptVar = '-=# TEST SCRIPT #=-'

return {
        on      = { timer = {'every minute'},
                    },
        
        logging = { level  = domoticz.LOG_ERROR,
       		        marker = scriptVar 
       		        },
       		
       		

execute = function(dz, device)
    local Stroom = dz.devices(97).WhActual  -- Change the name to your device
    local Dummy1 = dz.devices(944) -- Change the name to your device
    local Dummy2 = dz.devices(945) -- Change the name to your device
    
        dz.log('Stroom          :  ' .. Stroom ,dz.LOG_FORCE)
        dz.log('Dummy 1         :  ' .. Dummy1.state,dz.LOG_FORCE)
        dz.log('Dummy 2         :  ' .. Dummy2.state,dz.LOG_FORCE)


    if Stroom > 250 then
        Dummy1.switchOn().checkFirst()
        dz.log('Dummy 1 On > 250W', dz.LOG_FORCE)
        end
    if Stroom > 500 then
        Dummy2.switchOn().checkFirst()
        dz.log('Dummy 2 On > 500W', dz.LOG_FORCE)
        end
    if Stroom < 250 then
        Dummy1.switchOff().checkFirst()
        dz.log('Dummy 1 Off < 250W', dz.LOG_FORCE)
        end
    if Stroom < 500 then
        Dummy2.switchOff().checkFirst()
        dz.log('Dummy 2 Off < 500W', dz.LOG_FORCE)
        end
    end
}
Wilpshaar
Posts: 33
Joined: Friday 08 February 2019 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Dronten, NL
Contact:

Re: DzVents script turning on dummy switches when power use is negative

Post by Wilpshaar »

Hi all,

Now I see why it does not work, I read once from someone that negative values are not recognized, I see that now also in the log. Although current Wh is negative by production of solar panels (> 1000W) value stays '0'.

So DzVents neither Blockly will not be able to control a 2-stage boiler or loading an electric car, i.e. only power on my boiler if current power use is negative 1000W or have a 2nd step switching on something when current power is negative 2000W or more...

If someone nows a solution? Thanks for helping Patrick,
Attachments
not negative power
not negative power
NotNegative.png (22.15 KiB) Viewed 250 times
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: DzVents script turning on dummy switches when power use is negative

Post by madpatrick »

you can try a work around by making the negative into a positive value

Code: Select all

    local Stroom = dz.devices(97).WhActual * -1
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
Wilpshaar
Posts: 33
Joined: Friday 08 February 2019 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Dronten, NL
Contact:

Re: DzVents script turning on dummy switches when power use is negative

Post by Wilpshaar »

Thanks Patrick, I added the '*-1' and will test this weekend (if we see the sun althoug :D ). Now in the log negative values are returned so that is ok. If solar power and negative use we should see positive numbers then.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest