Who could help me out with a DZVents script for turning on dummy switches when power is negative? Seems blockly what I use can't work with negative numbers, don't get it work. Can someone create 2 Dummy switches called 'Dummy1' and 'Dummy2'. Then, if power is negative -750W switch on Dummy 1 and if power is negative -1500W switch on Dummy2. Of course is power becomes lower then -1500W Dummy2 should turn off and if lower then -750W Dummy1 should turn off. Who could help me out!
DzVents script turning on dummy switches when power use is negative
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:
DzVents script turning on dummy switches when power use is negative
Hi all,
Who could help me out with a DZVents script for turning on dummy switches when power is negative? Seems blockly what I use can't work with negative numbers, don't get it work. Can someone create 2 Dummy switches called 'Dummy1' and 'Dummy2'. Then, if power is negative -750W switch on Dummy 1 and if power is negative -1500W switch on Dummy2. Of course is power becomes lower then -1500W Dummy2 should turn off and if lower then -750W Dummy1 should turn off. Who could help me out!
Of course this is used for swithing on a 2-stage boiler. I power it on now telling power is <1 Watt and if solaredge is >1500W. But I want to be able to h
[/img][/img]ave a simple script which can turn of 2 switches when power is -750 and -1500W (as example).
Who could help me out with a DZVents script for turning on dummy switches when power is negative? Seems blockly what I use can't work with negative numbers, don't get it work. Can someone create 2 Dummy switches called 'Dummy1' and 'Dummy2'. Then, if power is negative -750W switch on Dummy 1 and if power is negative -1500W switch on Dummy2. Of course is power becomes lower then -1500W Dummy2 should turn off and if lower then -750W Dummy1 should turn off. Who could help me out!
- Attachments
-
- blockly example
- blocly.png (22.72 KiB) Viewed 1712 times
-
willemd
- Posts: 735
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: DzVents script turning on dummy switches when power use is negative
Blockly else-if is not really an else-if like you might be used to from other programming languages. Those else-if statements will all just be executed sequentially and tested. When true, the set statement will be executed.
So in the example:
Suppose power is -1000, then
First dummy1 will Not be switched on.
Second dummy2 will be switched on.
Third dummy one will be switched off.
Fourth dummy2 will Not be switched off.
So in the end dummy2 is on.
Is that what you want?
Suppose power is -500, then both dummy1 and dummy2 will be switched on (because > -750 and > -1500)
But if power is +500, then also they will both be switched on.
etc etc
So you need to add a few extra tests with and/or logic.
So in the example:
Suppose power is -1000, then
First dummy1 will Not be switched on.
Second dummy2 will be switched on.
Third dummy one will be switched off.
Fourth dummy2 will Not be switched off.
So in the end dummy2 is on.
Is that what you want?
Suppose power is -500, then both dummy1 and dummy2 will be switched on (because > -750 and > -1500)
But if power is +500, then also they will both be switched on.
etc etc
So you need to add a few extra tests with and/or logic.
- madpatrick
- Posts: 758
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.2
- Location: Netherlands
- Contact:
Re: DzVents script turning on dummy switches when power use is negative
I've setup quickly a simple script for you.
Not sure it will work, but give it a try.
Change the device number to your devices and try it.
Not sure it will work, but give it a try.
Change the device number to your devices and try it.
Code: Select all
local scriptVar = '-=# Switch Hal #=-'
return
{
on =
{
devices =
{
123, -- Change the name to your device
},
},
logging = { level = domoticz.LOG_INFO, -- change to domoticz.LOG_ERROR when all OK
marker = scriptVar
},
execute = function(dz, device)
local Stroom = dz.devices(123) -- Change the name to your device
local Dummy1 = dz.devices(234) -- Change the name to your device
local Dummy2 = dz.devices(345) -- Change the name to your device
if Stroom > -750 then
Dummy1.switchOn().checkFirst()
dz.log('Dummy 1 On', dz.LOG_FORCE)
elseif Stroom > -1500 then
Dummy1.switchOn().checkFirst()
dz.log('Dummy 2 On', dz.LOG_FORCE)
elseif Stroom < -750 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off', dz.LOG_FORCE)
elseif Stroom < -750 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', dz.LOG_FORCE)
end
end
}-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-
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
Thanks PAtrick, I just ready your reply now, I have the following now and see how it goes, will let you know,
Meaning should be;
If power use -250W turn on Dummy 1 (if more then -250 then switch off)
If power use -500W turn on Dummy 2 (if more then -500 then switch off)
This is for turning on or off 2 heating elements in a boiler, just how much power is consumed,
local scriptVar = '-=# Switch Hal #=-'
return
{
on =
{
devices =
{
Stroom, -- Change the name to your device
},
},
logging = { level = domoticz.LOG_INFO, -- change to domoticz.LOG_ERROR when all OK
marker = scriptVar
},
execute = function(dz, device)
local Stroom = dz.devices(Stroom) -- Change the name to your device
local Dummy1 = dz.devices(Dummy1) -- Change the name to your device
local Dummy2 = dz.devices(Dummy2) -- Change the name to your device
if Stroom > -250 then
Dummy1.switchOn().checkFirst()
dz.log('Dummy 1 On', dz.LOG_FORCE)
elseif Stroom > -500 then
Dummy2.switchOn().checkFirst()
dz.log('Dummy 2 On', dz.LOG_FORCE)
elseif Stroom < -250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off', dz.LOG_FORCE)
elseif Stroom < -250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', dz.LOG_FORCE)
end
end
}
Meaning should be;
If power use -250W turn on Dummy 1 (if more then -250 then switch off)
If power use -500W turn on Dummy 2 (if more then -500 then switch off)
This is for turning on or off 2 heating elements in a boiler, just how much power is consumed,
local scriptVar = '-=# Switch Hal #=-'
return
{
on =
{
devices =
{
Stroom, -- Change the name to your device
},
},
logging = { level = domoticz.LOG_INFO, -- change to domoticz.LOG_ERROR when all OK
marker = scriptVar
},
execute = function(dz, device)
local Stroom = dz.devices(Stroom) -- Change the name to your device
local Dummy1 = dz.devices(Dummy1) -- Change the name to your device
local Dummy2 = dz.devices(Dummy2) -- Change the name to your device
if Stroom > -250 then
Dummy1.switchOn().checkFirst()
dz.log('Dummy 1 On', dz.LOG_FORCE)
elseif Stroom > -500 then
Dummy2.switchOn().checkFirst()
dz.log('Dummy 2 On', dz.LOG_FORCE)
elseif Stroom < -250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off', dz.LOG_FORCE)
elseif Stroom < -250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', 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
HI PAtrick,
I am afraid nothing is happening? See nothing in the log, see no dummy switches changing, I could test when I remove the '-' (minus)
Thanks in advance, thanks for helping,
I am afraid nothing is happening? See nothing in the log, see no dummy switches changing, I could test when I remove the '-' (minus)
Thanks in advance, thanks for helping,
- Attachments
-
- DzVents.jpg (81.91 KiB) Viewed 1656 times
- madpatrick
- Posts: 758
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.2
- Location: Netherlands
- Contact:
Re: DzVents script turning on dummy switches when power use is negative
Is the script being triggered by the deviceWilpshaar wrote: Tuesday 20 September 2022 13:20 HI PAtrick,
I am afraid nothing is happening? See nothing in the log, see no dummy switches changing, I could test when I remove the '-' (minus)
Thanks in advance, thanks for helping,
Chamge otherwise the devicename for the IDX number
Please use CODE instead of image for script
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-
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
HI Patrick, for testing I use in the evening now of course positive power consumption but we could check working of script. Bit more happening now, have error in log "<name > expected near '97'. Any idea? Thanks!
local scriptVar = '-=# Switch Hal #=-'
return
{
on =
{
devices =
{
97, -- Change the name to your device
},
},
logging = { level = domoticz.LOG_INFO, -- change to domoticz.LOG_ERROR when all OK
marker = scriptVar
},
execute = function(dz, device)
local 97 = dz.devices(97) -- Change the name to your device
local 944 = dz.devices(944) -- Change the name to your device
local 945 = dz.devices(945) -- Change the name to your device
if 97 > 250 then
944.switchOn().checkFirst()
dz.log('Dummy 1 On', dz.LOG_FORCE)
elseif 97 >500 then
945.switchOn().checkFirst()
dz.log('Dummy 2 On', dz.LOG_FORCE)
elseif 97 < 500 then
945.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
elseif 97 < 250 then
944.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', dz.LOG_FORCE)
end
end
}
local scriptVar = '-=# Switch Hal #=-'
return
{
on =
{
devices =
{
97, -- Change the name to your device
},
},
logging = { level = domoticz.LOG_INFO, -- change to domoticz.LOG_ERROR when all OK
marker = scriptVar
},
execute = function(dz, device)
local 97 = dz.devices(97) -- Change the name to your device
local 944 = dz.devices(944) -- Change the name to your device
local 945 = dz.devices(945) -- Change the name to your device
if 97 > 250 then
944.switchOn().checkFirst()
dz.log('Dummy 1 On', dz.LOG_FORCE)
elseif 97 >500 then
945.switchOn().checkFirst()
dz.log('Dummy 2 On', dz.LOG_FORCE)
elseif 97 < 500 then
945.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
elseif 97 < 250 then
944.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', 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
Here overview of names/IDX and log
- Attachments
-
- DZ.png (197.23 KiB) Viewed 1643 times
- madpatrick
- Posts: 758
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.2
- Location: Netherlands
- Contact:
Re: DzVents script turning on dummy switches when power use is negative
Just a quick try
PLEASE use CODE for the script.
Otherwise it makes the thread unreadable
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(94).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', dz.LOG_FORCE)
elseif Stroom > -500 then
Dummy2.switchOn().checkFirst()
dz.log('Dummy 2 On', dz.LOG_FORCE)
elseif Stroom < -250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off', dz.LOG_FORCE)
elseif Stroom < -250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', dz.LOG_FORCE)
end
end
}
Otherwise it makes the thread unreadable
Last edited by madpatrick on Tuesday 20 September 2022 20:22, edited 1 time in total.
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
- madpatrick
- Posts: 758
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.2
- Location: Netherlands
- Contact:
Re: DzVents script turning on dummy switches when power use is negative
Please copy/paste the text and an image
This not readable like this
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-
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
Hi Patrick, looks better!
LOG:
2022-09-20 21:01:00.641 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 460
2022-09-20 21:01:00.641 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-20 21:01:00.641 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:01:00.642 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On
LOG:
2022-09-20 21:01:00.641 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 460
2022-09-20 21:01:00.641 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-20 21:01:00.641 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:01:00.642 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On
-
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
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 > 500 then
Dummy1.switchOn().checkFirst()
dz.log('Dummy 1 On', dz.LOG_FORCE)
elseif Stroom > 1000 then
Dummy2.switchOn().checkFirst()
dz.log('Dummy 2 On', dz.LOG_FORCE)
elseif Stroom < 500 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off', dz.LOG_FORCE)
elseif Stroom < 1000 then
Dummy2.switchOff().checkFirst()
dz.log('Dummy 2 Off', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', 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
2022-09-20 21:08:00.211 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 420
2022-09-20 21:08:00.211 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-20 21:08:00.211 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:08:00.211 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 Off
2022-09-20 21:08:00.211 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-20 21:08:00.211 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:08:00.211 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 Off
-
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
2022-09-20 21:09:00.268 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 1430
2022-09-20 21:09:00.268 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : Off
2022-09-20 21:09:00.268 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:09:00.268 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On
2022-09-20 21:09:00.268 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : Off
2022-09-20 21:09:00.268 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:09:00.268 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On
-
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
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)
elseif Stroom > 1000 then
Dummy2.switchOn().checkFirst()
dz.log('Dummy 2 On > 1000W', dz.LOG_FORCE)
elseif Stroom < 250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off < 250W', dz.LOG_FORCE)
elseif Stroom < 1000 then
Dummy2.switchOff().checkFirst()
dz.log('Dummy 2 Off < 1000W', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', 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
I changed the log text a bit to understand and see what happens
-
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
I don't see the dummy2 switching on when power exceeds 1000W
2022-09-20 21:15:59.081 Status: boiler uitschakelen
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 1520
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On > 250W
2022-09-20 21:15:59.081 Status: boiler uitschakelen
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 1520
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : On
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-20 21:16:00.304 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On > 250W
- madpatrick
- Posts: 758
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.2
- Location: Netherlands
- Contact:
Re: DzVents script turning on dummy switches when power use is negative
That is of the "elseif" function
Change it to "if"
Try to play with the script.
It is pretty easy and there are enough example or see : https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Change it to "if"
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 > 1000 then
Dummy2.switchOn().checkFirst()
dz.log('Dummy 2 On > 1000W', dz.LOG_FORCE)
end
if Stroom < 250 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off < 250W', dz.LOG_FORCE)
end
if Stroom < 1000 then
Dummy2.switchOff().checkFirst()
dz.log('Dummy 2 Off < 1000W', dz.LOG_FORCE)
end
end
}It is pretty easy and there are enough example or see : https://www.domoticz.com/wiki/DzVents:_ ... _scripting
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-
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
HI Patrick, I think I am doing something wrong again, currently power is over minus 1200W
2022-09-21 10:08:05.841 ...cz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua:39: unexpected symbol near '}'
2022-09-21 10:08:06.017 Error: dzVents: Error: (3.1.8) error loading module '17_Test_DzVents' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua':
2022-09-21 10:08:06.017 ...cz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua:39: unexpected symbol near '}'
2022-09-21 10:08:15.835 EventSystem: Event triggered: 10_Electroboiler omvormer_1
2022-09-21 10:08:15.836 Status: boiler opwarmen
2022-09-21 10:08:15.784 Error: dzVents: Error: (3.1.8) error loading module '17_Test_DzVents' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua':
2022-09-21 10:08:15.784 ...cz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua:39: unexpected symbol near '}'
2022-09-21 10:08:25.815 EventSystem: Event triggered: 10_Electroboiler omvormer_1
2022-09-21 10:08:25.816 Status: boiler opwarmen
2022-09-21 10:08:25.774 Error: dzVents: Error: (3.1.8) error loading module '17_Test_DzVents' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua':
2022-09-21 10:08:05.841 ...cz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua:39: unexpected symbol near '}'
2022-09-21 10:08:06.017 Error: dzVents: Error: (3.1.8) error loading module '17_Test_DzVents' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua':
2022-09-21 10:08:06.017 ...cz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua:39: unexpected symbol near '}'
2022-09-21 10:08:15.835 EventSystem: Event triggered: 10_Electroboiler omvormer_1
2022-09-21 10:08:15.836 Status: boiler opwarmen
2022-09-21 10:08:15.784 Error: dzVents: Error: (3.1.8) error loading module '17_Test_DzVents' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua':
2022-09-21 10:08:15.784 ...cz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua:39: unexpected symbol near '}'
2022-09-21 10:08:25.815 EventSystem: Event triggered: 10_Electroboiler omvormer_1
2022-09-21 10:08:25.816 Status: boiler opwarmen
2022-09-21 10:08:25.774 Error: dzVents: Error: (3.1.8) error loading module '17_Test_DzVents' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/17_Test_DzVents.lua':
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 > -500 then
Dummy1.switchOn().checkFirst()
dz.log('Dummy 1 On > 250W', dz.LOG_FORCE)
if Stroom > -1000 then
Dummy2.switchOn().checkFirst()
dz.log('Dummy 2 On > 1000W', dz.LOG_FORCE)
if Stroom < -500 then
Dummy1.switchOff().checkFirst()
dz.log('Dummy 1 Off < 250W', dz.LOG_FORCE)
if Stroom < -1000 then
Dummy2.switchOff().checkFirst()
dz.log('Dummy 2 Off < 1000W', dz.LOG_FORCE)
else
dz.log('Geen actie nodig ', dz.LOG_FORCE)
end
end
}- madpatrick
- Posts: 758
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.2
- Location: Netherlands
- Contact:
Re: DzVents script turning on dummy switches when power use is negative
See my previous post.
You are forgetting END after the IF function
This my log now:
You are forgetting END after the IF function
This my log now:
Code: Select all
2022-09-21 16:29:00.084 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Stroom : 923.758
2022-09-21 16:29:00.084 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 : Off
2022-09-21 16:29:00.084 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 : Off
2022-09-21 16:29:00.084 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 1 On > 250W
2022-09-21 16:29:00.084 Status: dzVents: !Info: -=# TEST SCRIPT #=-: Dummy 2 Off < 1000W-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
Who is online
Users browsing this forum: No registered users and 1 guest