Page 2 of 2

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

Posted: Wednesday 21 September 2022 19:16
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
}

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

Posted: Thursday 22 September 2022 10:02
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,

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

Posted: Thursday 22 September 2022 10:12
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

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

Posted: Friday 23 September 2022 18:51
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.