Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Moderator: leecollings
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
@dannybloe Thank you!
That is a very straight forward and comprehensible script.
I can't wait to start testing it.
That is a very straight forward and comprehensible script.
I can't wait to start testing it.
-
- Posts: 32
- Joined: Tuesday 14 June 2016 21:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I haven't even started to use blockly or let alone Lua for scripting. But this makes me want to start doing script. Looks very nice and intuitive.
But I wonder what is the time plan for getting this as a part of Domoticz? Is there a pull request or something where I can watch the progress? Could even blockly get support for this in some way?
But I wonder what is the time plan for getting this as a part of Domoticz? Is there a pull request or something where I can watch the progress? Could even blockly get support for this in some way?
-
- Posts: 22
- Joined: Monday 21 March 2016 1:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Finally got it working, I had a scene with the same name as my thermostat "Dining". once i renamed the scene with a different name the dzVents script worked. Thanks for all your help.dannybloe wrote:That's really strange. Can you try to give the device the same name in production as it has on your poc machine? There must be some discrepancy between the two machines. I suspect the naming may be the culprit as Domoticz doesn't use ids but names in the Lua tables it provides to the scripts. I have to do some juggling to match all those tables to the same devices but it's all done by name.ddahya wrote:Its working on my PoC machine but not my Prod box.
If you look at the device attributes from my prod machine it's missing,
2016-08-06 10:40:20.641 LUA: > utility: 23
2016-08-06 10:40:20.642 LUA: > state: 23.00
2016-08-06 10:40:20.643 LUA: > _sValues: 23.00
these are in the PoC box.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
There is nothing there yet. As far as I know, Gizmocus is planning to or working on it right now to have a better and more reliable information stream to the event system so dzVents can be integrated more easily. But I'm not sure how that goes as he's on vacation right now.raptorjr wrote:I haven't even started to use blockly or let alone Lua for scripting. But this makes me want to start doing script. Looks very nice and intuitive.
But I wonder what is the time plan for getting this as a part of Domoticz? Is there a pull request or something where I can watch the progress? Could even blockly get support for this in some way?
So there are two options: a) it's integrated as-is. That means you will have to rely on getting extra data through http (json calls) which is a bit fragile on not truly live or b) integrate it and have a better stream of data coming into the event system (and therefore dzVents as it is just another event script, though a bit more clever) so you have access to all the data in Domoticz directly and live.
a) doesn't require any C++ knowledge and b) does. I don't have C++ knowledge so I'd have to rely on someone else here or we just have to go with option a). Option a) is different from what we have now in that now you have to put dzVents in your system manually. Advantage is that I can update dzVents outside the update cycle of Domoticz.
But I'd rather have option b).
So, until that's there I'd suggest to just start using it coz it doesn't seem likely that dzVents is going away anytime soon
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
@dannybloe
I do have a question now that I have been running the script...
EventSystem: Lua script Washing machine did not return a commandArray
Do I need to encapsulate the script using Commandarray() ?
I do have a question now that I have been running the script...
EventSystem: Lua script Washing machine did not return a commandArray
Do I need to encapsulate the script using Commandarray() ?
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
That should not be necessary as the scripts always return a commandArray. Maybe you can set the loglevel to 1.5 and see what it prints. It should show you the commandArray in the log for each script. (you may have to try it with the dev branch though).Abbell wrote:@dannybloe
I do have a question now that I have been running the script...
EventSystem: Lua script Washing machine did not return a commandArray
Do I need to encapsulate the script using Commandarray() ?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 32
- Joined: Tuesday 14 June 2016 21:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
How can I find out which device triggered the script? If I have several switches in the on-section.
I see this in the tutorial "A 'devices' table holding a list of device names or ids: 'devices' = { 'deviceNameA', 'deviceNameB'}. This can be useful if you have a variable holding the devices that you use for defining the triggers and use in your code."
But don't understand if that is something that I need to use?
I see this in the tutorial "A 'devices' table holding a list of device names or ids: 'devices' = { 'deviceNameA', 'deviceNameB'}. This can be useful if you have a variable holding the devices that you use for defining the triggers and use in your code."
But don't understand if that is something that I need to use?
-
- Posts: 32
- Joined: Tuesday 14 June 2016 21:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Another question. I have a water volume device, it shows total litres and something that seems to be current m3 value. Litres seems to be impossible to use or reset, and is now only a nonsense value( 5350 litres and I just added that device???)
But m3 seems to actually be the value I need, the current volume, and is possible to reset. But I don't know how I can access that m3 value from dzVents?
But m3 seems to actually be the value I need, the current volume, and is possible to reset. But I don't know how I can access that m3 value from dzVents?
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I think that has to do with the way Domoticz works with counter devices. dzVents is only using what Domoticz is sending to the script engine.raptorjr wrote:Another question. I have a water volume device, it shows total litres and something that seems to be current m3 value. Litres seems to be impossible to use or reset, and is now only a nonsense value( 5350 litres and I just added that device???)
But m3 seems to actually be the value I need, the current volume, and is possible to reset. But I don't know how I can access that m3 value from dzVents?
Anyway, I'm not entirely sure what you question is. Are you just looking for the current value?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 32
- Joined: Tuesday 14 June 2016 21:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
My question is how do I read the water volume value? The value that on this picture is 0.000m3.
The value 0 Liter is accumulated, and not what I need.
The value 0 Liter is accumulated, and not what I need.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
See the documentation for devices: Device attributes. myDevice.counterToday or counterTotal should do it. (but you have to have http fetching enabled.raptorjr wrote:My question is how do I read the water volume value? The value that on this picture is 0.000m3.
The value 0 Liter is accumulated, and not what I need.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 13
- Joined: Monday 19 September 2016 8:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
dzvEnts is an awesome framework Thx a lot @dannybloe !!!!
Is it possible to use a function in the timer section too?
I've got the problem that I use several scripts for my blinds which should only be executed when it is sunrise or sunset. I'm checking the domoticz.time.isDayTime or domoticz.time.isNightTime attribute
But I've got the problem that not all of them get executed everytime. Sometimes my blinds will open or close, sometimes not because the event is missed by Domoticz. So I want to run the script again e.g. 3 minutes after sunrise/sunset. I've written a lua script which is able to calculate that time but how can I include this with dzevents timer?
I've already tried to put the value in a globalData Variable & use this with the timer event, but no luck. Alternatively something like '3 minutes after sunset' would be great
Any help is appreciated...
Is it possible to use a function in the timer section too?
I've got the problem that I use several scripts for my blinds which should only be executed when it is sunrise or sunset. I'm checking the domoticz.time.isDayTime or domoticz.time.isNightTime attribute
Code: Select all
return {
active = true,
on = {
['timer'] = 'at sunset',
['timer'] = 'at sunrise'
...
if ( domoticz.time.isNightTime and myLevelBlinds > 20) then
domoticz.devices['Blinds'].dimTo(10)
I've already tried to put the value in a globalData Variable & use this with the timer event, but no luck. Alternatively something like '3 minutes after sunset' would be great
Any help is appreciated...
RPi3+UZB1,FIBARO FGMS001(9x),FIBARO FGD212,FIBARO FGRM222(6x),FIBARO FGSD002(1x),FIBARO FGWPE (3x),Neo CoolCam Power plug(5x),NodOn CRC-3-1 Remote(2x),Qubino ZMNHADx(1x),Qubino ZMNHDD1(2x),Z-Wave Weather Sensor(1x),Z-Wave ZME_WALLC-S,FIBARO System FGK10x
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
So why don't you just set a timer for let's say every couple of minutes and in the script check if it is sunrise or sunset and check the state of your blinds and act accordingly? That shouldn't be too hard I think.Glatzi wrote:dzvEnts is an awesome framework Thx a lot @dannybloe !!!!
Is it possible to use a function in the timer section too?
I've got the problem that I use several scripts for my blinds which should only be executed when it is sunrise or sunset. I'm checking the domoticz.time.isDayTime or domoticz.time.isNightTime attribute
But I've got the problem that not all of them get executed everytime. Sometimes my blinds will open or close, sometimes not because the event is missed by Domoticz. So I want to run the script again e.g. 3 minutes after sunrise/sunset. I've written a lua script which is able to calculate that time but how can I include this with dzevents timer?Code: Select all
return { active = true, on = { ['timer'] = 'at sunset', ['timer'] = 'at sunrise' ... if ( domoticz.time.isNightTime and myLevelBlinds > 20) then domoticz.devices['Blinds'].dimTo(10)
I've already tried to put the value in a globalData Variable & use this with the timer event, but no luck. Alternatively something like '3 minutes after sunset' would be great
Any help is appreciated...
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Is is possible to create persistent data variables dynamically? Like with an existing array of variables that holds the names of the persistent data variables to be created...
and then in the data = { } part something magic.
Maybe use something like loadstring("arrDataVars[1] = { initial = 0 }") ??
instead of
Any help would be great
Code: Select all
local arrDataVars = {'Counter1', 'Counter2', 'Counter3'}
Maybe use something like loadstring("arrDataVars[1] = { initial = 0 }") ??
instead of
Code: Select all
data = {
Counter1 = { initial = 0 },
Counter2 = { initial = 0 },
Counter3 = { initial = 0 }
}
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
It is even simpler than that. Simply create a table variable:Eduard wrote:Is is possible to create persistent data variables dynamically? Like with an existing array of variables that holds the names of the persistent data variables to be created...
and then in the data = { } part something magic.Code: Select all
local arrDataVars = {'Counter1', 'Counter2', 'Counter3'}
Maybe use something like loadstring("arrDataVars[1] = { initial = 0 }") ??
instead of
Any help would be greatCode: Select all
data = { Counter1 = { initial = 0 }, Counter2 = { initial = 0 }, Counter3 = { initial = 0 } }
Code: Select all
data = {
myVar = { initial = {} }
}
Code: Select all
domoticz.data.myVar['counter1'] = 1;
domoticz.data.myVar['counter2'] = 2;
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Aah cool. I will try that. Thanks!!dannybloe wrote:It is even simpler than that. Simply create a table variable:
Then you can do this:Code: Select all
data = { myVar = { initial = {} } }
That should work.Code: Select all
domoticz.data.myVar['counter1'] = 1; domoticz.data.myVar['counter2'] = 2;
-
- Posts: 485
- Joined: Thursday 17 September 2015 10:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Hi there!
I will try to migrate my current LUA scripts to dzVents.
In several of my old LUA scripts I call require to load a module with some handy functions that I use frequently. I use those functions frequently, for example when I want to have a message spoken out loud in the kitchen (using AutoRemote and Tasker):
I'm now trying to figure out the nicest and most elegant way to use my custom functions in dzVents scripts. I guess I could just use require to load a module as in the code above... I wish there was a some kind of hook mechanism or a way to "extend" the domoticz object in my dzVents script so that I could just issue a command like
Any ideas about that? Thanks!
I will try to migrate my current LUA scripts to dzVents.
In several of my old LUA scripts I call require to load a module with some handy functions that I use frequently. I use those functions frequently, for example when I want to have a message spoken out loud in the kitchen (using AutoRemote and Tasker):
Code: Select all
local b = require("scripts/lua/mymodule")
b.speak("Hello world")
Code: Select all
domoticz.speak('Hello world', domoticz.PRIORITY_NORMAL)
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
That's an interesting idea. Shouldn't be so hard to do that. Until then I'd just do the require way.BakSeeDaa wrote:Hi there!
I will try to migrate my current LUA scripts to dzVents.
In several of my old LUA scripts I call require to load a module with some handy functions that I use frequently. I use those functions frequently, for example when I want to have a message spoken out loud in the kitchen (using AutoRemote and Tasker):I'm now trying to figure out the nicest and most elegant way to use my custom functions in dzVents scripts. I guess I could just use require to load a module as in the code above... I wish there was a some kind of hook mechanism or a way to "extend" the domoticz object in my dzVents script so that I could just issue a command likeCode: Select all
local b = require("scripts/lua/mymodule") b.speak("Hello world")
Any ideas about that? Thanks!Code: Select all
domoticz.speak('Hello world', domoticz.PRIORITY_NORMAL)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 485
- Joined: Thursday 17 September 2015 10:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Thanks @dannybloedannybloe wrote:That's an interesting idea. Shouldn't be so hard to do that. Until then I'd just do the require way.
I have the following function in my module:
Code: Select all
function b.OpenURL(url)
-- The commandArray also supports nested tables to send the same command type multiple times.
-- To do this, give the command a numeric index
commandArray[#commandArray + 1]={['OpenURL']=url }
end
While my old LUA scripts was working with that code, I now have a problem with that I have no valid commandArray object reference. Also, my module doesn't seem to be able to access the domoticz object so I have currently no way to add something to the command array or access domoticz user variables... Maybe there is a way to solve that?
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
domoticz.commandArray is exactly the commandArray that is sent back to domoticz. You can see in Domoticz.lua how the array is filled.BakSeeDaa wrote:Thanks @dannybloedannybloe wrote:That's an interesting idea. Shouldn't be so hard to do that. Until then I'd just do the require way.
I have the following function in my module:
It allows me to call multiple URLs.Code: Select all
function b.OpenURL(url) -- The commandArray also supports nested tables to send the same command type multiple times. -- To do this, give the command a numeric index commandArray[#commandArray + 1]={['OpenURL']=url } end
While my old LUA scripts was working with that code, I now have a problem with that I have no valid commandArray object reference. Also, my module doesn't seem to be able to access the domoticz object so I have currently no way to add something to the command array or access domoticz user variables... Maybe there is a way to solve that?
Can't you pass domoticz.commandArray to your function and have you function use the parameter instead of the global commandAarray? dzVentz overwrites the global commandArray at the end of the script run.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Who is online
Users browsing this forum: Google [Bot] and 1 guest