Page 7 of 17

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 14:16
by NietGiftig
Then you have to wait until the master guru himself returns in the forum.
The last time I synchronized was yesterday morning, no errors whatsoever then

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 14:28
by woody4165
maybe there something in my system...
Just to understand if I am doig right:

Code: Select all

Copy the following to the Domoticz script folder: /path/to/domoticz/scripts/lua:

event_helpers.lua
script_time_main.lua
script_device_main.lua
Domoticz.lua
dzVents_settings.lua and
the folder scripts
Here is written event_helper.lua but the file in the zip is EventHelpers.lua (same name already exist in the /domoticz/scripts/lua folder and I let this one overwrite the other).

This is the only things to do except for modification in the dzVents_settings.lua), right?

Thanks

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 15:04
by NietGiftig
Here is written event_helper.lua


in my folder it is called event_helpers.lua

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 15:09
by woody4165
I missed the s in the post, sorry.

In any case I tried with both, event_helpers.lua and EventHelpers.lua like now you can find in the GitHub folder.

I'll wait for some news...

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 15:21
by NietGiftig
But you are sure you tried the 0.9.13 branch on github?
And start fresh empty dir and so?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 15:31
by woody4165
:oops: Nope! I was using the master one

Shame on me.

Now it's working!!!

I didn't noticed the branches...

Thanks!!!

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 15:38
by NietGiftig
reading help from other people is mandatory if you ask for help :shock:

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 16:15
by dannybloe
:evil: :evil: Grrr. notifications for new posts is still not working well.. so I miss new posts here every now and then, sorry about that ..

Indeed.. master branch is currently in flux. I'm refactoring stuff so that installing is even easier (and I wrote 120+ unit-tests for it this weekend for future stability (and caught a few bugs while doing this)).

So, yeah, stick to the tags when installing for now. In the future I will make the master branch the stable one and do dev stuff in another branch.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 21 March 2016 16:24
by NietGiftig
dannybloe wrote::evil: :evil: Grrr. notifications for new posts is still not working well.. so I miss new posts here every now and then
I
I have the Idea (not sure) that if you do not click on the latest notification, you are not going to get a new one

Upgrading dzVents

Posted: Tuesday 22 March 2016 14:14
by commodore white
[smug mode] I have to say that all I do to snarf the latest version is: download the zip, unpack it to an empty directory then copy the whole kit and kaboodle EXCEPT THE SETTINGS file to the domoticz/scripts/lua on my Pi

One day I'll come a cropper because Garry will have changed the settings file, but until then ...

[/smug mode]

Some daredevils needed

Posted: Tuesday 22 March 2016 21:41
by dannybloe
Today I finished refactoring dzVents. As I said earlier, I wrote around 130 unit tests for the code and I moved most of the dzVents code to a subfolder. I also added some new functionality (from the history.txt):
  • Added SMS method.
  • Added toggleSwitch() method to devices that support it.
  • Added more switch states that control device.bState (e.g. on == true, open == true etc)
  • Added secondsAgo next to minutesAgo to the device.lastUpdate attribute
And I updated the documentation mostly regarding the instructions on how to install it (read that part!!!).

So, my intention is that this will become version 1.0 but before releasing it I ask anyone who dares ;-) to test the master branch (perhaps make a copy of your entire lua folder so you can easily restore it). I have tested it locally here and all seems fine.

Fingers crossed :roll:

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 22 March 2016 22:11
by remb0
Lua editor in domoticz is fully compatible with this?
Maybe when its finished it can Be obtained in domoticz?

I Will test tomorrow and put an install script for it in my script.

https://github.com/remb0/Domoticz_configurator

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 22 March 2016 22:21
by dannybloe
remb0 wrote:Lua editor in domoticz is fully compatible with this?
You mean the one that runs in the browser? I don't think so. dzVents has it's own mechanism to figure out which script needs to be called (based on the triggers and active state and timer states). The problem is that the scripts that can be edited inside Domoticz don't live on the file system but in the database. That means that the script dispatchers from dzVents cannot find them and cannot call them. You could pass the domoticz object to these scripts with a bit of effort for easy controlling of the domoticz devices but you would miss some part of the fun.

It would have been nice if the script editor in Domoticz would have stored the scripts on the filesystem as was suggested by a couple of people. That would have made this an awesome combination I guess.
Maybe when its finished it can Be obtained in domoticz?

I Will test tomorrow and put an install script for it in my script.

https://github.com/remb0/Domoticz_configurator
Nice!

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 22 March 2016 22:41
by NietGiftig
eh, ;-)

Code: Select all

2016-03-22 22:36:11.738 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/EventHelpers.lua:3: module 'utils' not found:
no field package.preload['utils']
no file '/usr/local/share/lua/5.2/utils.lua'
no file '/usr/local/share/lua/5.2/utils/init.lua'
no file '/usr/local/lib/lua/5.2/utils.lua'
no file '/usr/local/lib/lua/5.2/utils/init.lua'
no file './utils.lua'
no file '/home/pi/domoticz/scripts/lua//utils.lua'
no file '/home/pi/domoticz/scripts/lua/dzVents/utils.lua'
no file '/home/pi/domoticz/scripts/lua/scripts/utils.lua'
no file '/usr/local/lib/lua/5.2/utils.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './utils.so'
I have to read it again i think or something to do with rights?
Files copied from windows

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 22 March 2016 23:03
by dannybloe
Can you print the package path right after it is constructed in de main scripts?

Are you sure you did exactly as described in the readme? Replaced all the files with the new ones?

There should be a folder dzEvents inside the lua folder.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 22 March 2016 23:13
by NietGiftig
I will try tomorrow again, I was pretty sure that I followed the "Instructions"
But for now i have put the old scripts back.
Tomorrow another try, with fresh mind

eh?
Can you print the package path right after it is constructed in de main scripts?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 22 March 2016 23:15
by NietGiftig
By the way the file devices.lua cannot be removed i see?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 23 March 2016 8:02
by dannybloe
NietGiftig wrote:I will try tomorrow again, I was pretty sure that I followed the "Instructions"
But for now i have put the old scripts back.
Tomorrow another try, with fresh mind

eh?
Can you print the package path right after it is constructed in de main scripts?
In script_device_main.lua or script_time_main.lua at line 7 add

Code: Select all

print(package.path)
and look in the logs what the result is.

And devices.lua contains the data that is fetched from Domoticz through http for additional data like battery status. You should be able to remove it. If you have set ['Enable http fetch'] = true in the settings file then it will automatically be refetched after a while.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 23 March 2016 8:32
by NietGiftig
And here are the results:

Code: Select all

 2016-03-23 08:24:09.316 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/EventHelpers.lua:3: module 'utils' not found:
no field package.preload['utils']
no file '/usr/local/share/lua/5.2/utils.lua'
no file '/usr/local/share/lua/5.2/utils/init.lua'
no file '/usr/local/lib/lua/5.2/utils.lua'
no file '/usr/local/lib/lua/5.2/utils/init.lua'
no file './utils.lua'
no file '/home/pi/domoticz/scripts/lua//utils.lua'
no file '/home/pi/domoticz/scripts/lua/dzVents/utils.lua'
no file '/home/pi/domoticz/scripts/lua/scripts/utils.lua'
no file '/usr/local/lib/lua/5.2/utils.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './utils.so'
2016-03-23 08:24:42.915 LUA: /usr/local/share/lua/5.2/?.lua;/usr/local/share/lua/5.2/?/init.lua;/usr/local/lib/lua/5.2/?.lua;/usr/local/lib/lua/5.2/?/init.lua;./?.lua;/home/pi/domoticz/scripts/lua//?.lua;/home/pi/domoticz/scripts/lua/dzVents/?.lua;/home/pi/domoticz/scripts/lua/scripts/?.lua 

It seems that on the Domoticz image no lua 5.2 is installed.
There is no /usr/local/share/lua on my system

The file '/home/pi/domoticz/scripts/lua/dzVents/utils.lua' is named Utils.lua

Installed from the zip file.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 23 March 2016 9:58
by dannybloe
These package paths are provided by the lua system itself instead of the stuff that I add to it.
I commited some changes in master. Could you try this? The utils.lua file should be with a capital now and both _main.lua files have been changed as well.