Page 1 of 1

DzBasic - Another simple script system

Posted: Thursday 06 May 2021 22:37
by cyril21
Hello all,

I share with you a project that I am developing in lua/dzvents.
This is another scripting system. The code (a basic like language) is put in the description field of the device (see screenshot below). It is interpreted every minute and every time the device is triggered.

Have a look here:
- Examples of dzbasic code, to understand better its capabilities
- Github with the code and a light documentation

This is a beta version, so probably with bugs...

Hope it will be useful for you :D
dzbasic1.png
dzbasic1.png (302.96 KiB) Viewed 1176 times

Re: DzBasic - Another simple script system

Posted: Friday 07 May 2021 1:15
by waaren
cyril21 wrote: Thursday 06 May 2021 22:37 I share with you a project that I am developing in lua/dzvents.
This is another scripting system. The code (a basic like language) is put in the description field of the device (see screenshot below). It is interpreted every minute and every time the device is triggered.
@cyril21,

Thx for sharing, It looks like you spend a lot of time and thoughts on it.

I am probably not in the best position to comment if this scripting approach is easier to understand compared to dzVents or Lua because the experience I gained of these languages / framework by coding and supporting them; so I leave that to others.

However I am in a position to comment on aspects like performance, repsonse-times and resource usage.

I installed your scripts on my relatively quiet test and development system and notice the script is executed > 10 times a minute even now at the most quiet period of the day. In every execution the script reads and interprets all description fields of every device to see if any action needs to be taken.
My system is heavily oversized for what it is intended for but I see that the average execution time of your script without any action to be taken is 0.19 seconds so I expect this to be no less on a Raspberry with a similar amount of devices. On average my other dzVents scripts execution time on this system (with actions performed) is 0.004 seconds.
When this script is executing any other Blockly, Lua or dzVents script needs to wait until it is finished.

Have you looked at the additional CPU and memory usage on a system with a reasonable amount of devices?

btw. It would have been nice if you gave the appropriate credits to @dannybloe (creator of the dzVents framework)

Re: DzBasic - Another simple script system

Posted: Sunday 09 May 2021 23:24
by cyril21
Hello,
Thank you for your reply and your tests.
I was unable to reproduce your results with 24 devices . But I'm not sure to have the appropriate method to test the performance (I used os.clock command).
I did make some improvements (ex: only devices with code are scanned), and I will continue my investigations regarding your advices.

Re: DzBasic - Another simple script system

Posted: Monday 10 May 2021 0:01
by waaren
cyril21 wrote: Sunday 09 May 2021 23:24 I was unable to reproduce your results with 24 devices.
24 devices it not reflecting a typical domoticz setup for users starting with scripting. And the amount of devices is only one part of the equation. For example some smart meter devices do update several devices every 10 seconds.
But I'm not sure to have the appropriate method to test the performance (I used os.clock command).
os.clock can measure only that part of the time where your script is already started en just before it finished. The time spend in dzVents.cpp and dzVents.lua before the script starts and after the script finished is left out
I did make some improvements (ex: only devices with code are scanned), and I will continue my investigations regarding your advices.
What I see in dzbasic.lua is that it still interprets all description strings. Do I overlook something?

Re: DzBasic - Another simple script system

Posted: Wednesday 19 May 2021 22:30
by cyril21
Hello,

Thanks again for your comments.
What I see in dzbasic.lua is that it still interprets all description strings. Do I overlook something?
In fact it scans the devices but does not interpret the strings. A list of devices is stored in a persistent variable.

I just released a new version which I think should improve this. This version executes the "dzvents execute function" only for updated devices which include a dzbasic code.

Re: DzBasic - Another simple script system

Posted: Wednesday 19 May 2021 23:52
by waaren
cyril21 wrote: Wednesday 19 May 2021 22:30 I just released a new version which I think should improve this. This version executes the "dzvents execute function" only for updated devices which include a dzbasic code.
Good improvement! Initial tests showed indeed significant less resource usage.

Re: DzBasic - Another simple script system

Posted: Saturday 03 July 2021 18:16
by cyril21
Hello,
Not with this script. But it could be possible to add this function in a next version.
Take a look here instead: viewtopic.php?f=59&t=36400