Script editor Topic is solved

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

theolsen
Posts: 46
Joined: Wednesday 31 July 2013 11:15
Target OS: -
Domoticz version:
Contact:

Script editor

Post by theolsen »

Here's an idea.

I don't know if it is even possible but it would be uber cool if we had a script editor built into the Domoticz web gui.
Any text (and filename) entered in here could be written directly to the lua folder on the host device.

-theolsen.
bistoury
Posts: 35
Joined: Friday 12 July 2013 14:14
Target OS: -
Domoticz version:
Contact:

Re: Script editor

Post by bistoury »

+1
good idea
pepijn
Posts: 251
Joined: Friday 12 July 2013 13:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Script editor

Post by pepijn »

-1
The eventsystem (Blocky) is designed to create events (lua) scripts for regular users. The scripts are saved in the Domoticz database witch can be backed up through the gui.
User avatar
Dynamic
Posts: 109
Joined: Friday 12 July 2013 14:50
Target OS: -
Domoticz version:
Location: Enschede
Contact:

Re: Script editor

Post by Dynamic »

+1.
I do not always have SSH-access to my Pi, but the web-interface is always available. Would be great to have a webbased editor. But I think it should be hidden for 'normal' users (checkbox in settings?).
theolsen
Posts: 46
Joined: Wednesday 31 July 2013 11:15
Target OS: -
Domoticz version:
Contact:

Re: Script editor

Post by theolsen »

Dynamic wrote:+1.
I do not always have SSH-access to my Pi, but the web-interface is always available. Would be great to have a webbased editor. But I think it should be hidden for 'normal' users (checkbox in settings?).

Exactly my reasoning.

Moreover it would enable scripting from a tablet device.
bistoury
Posts: 35
Joined: Friday 12 July 2013 14:14
Target OS: -
Domoticz version:
Contact:

Re: Script editor

Post by bistoury »

I would also add that blocky does not give the same flexibility as LUA.
For instance, and IF/DO/ELSE/DO/END statement embedded into another IF/DO/ELSE/DO/END is not possible in blocky.

So having a web-based LUA editor would be a very welcome new functionality.

so +1.

bistoury.
pepijn
Posts: 251
Joined: Friday 12 July 2013 13:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Script editor

Post by pepijn »

Dynamic wrote:+1.
I do not always have SSH-access to my Pi,
Try installing shellinabox this gives you full web based ssh access. All you need is a webserver running. If you use the Domoticz SD card it comes with nginx installed for secure https access.
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Script editor

Post by simonrg »

-1

While I think having a LUA IDE built into Domoticz would be neat and potentially platform independent. I would prefer the skilled programming effort was put into extending / supporting the core capabilities of Domoticz.

Pepijn's suggestion of Shellinabox sounds like a good approach. Even more so having set it and played with it all in 5 minutes.

I would like to suggest a compromise, based on pepijn's suggestion, to include Shellinabox configured on the Domoticz SD card and to explain how to set it up on the Wiki.

In fact using Shellinabox seems to be very easy on Raspberry Pi simply two commands:

Code: Select all

sudo apt-get install shellinabox
shellinaboxd --port=4201 -t -s /:AUTH:HOME:/bin/bash
Now in a web browser http://192.168.1.111:4201 opens a shell in my web browser which allows me to modify LUA scripts.

This means that Domoticz does the automation it's good at and Shellinabox plus all the command line tools looks after all the security issues etc..
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
theolsen
Posts: 46
Joined: Wednesday 31 July 2013 11:15
Target OS: -
Domoticz version:
Contact:

Re: Script editor

Post by theolsen »

Just installed Shellinabox - very nice indeed!

Thanks for the suggestions.

-theolsen.
sdh
Posts: 4
Joined: Tuesday 25 March 2014 3:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Script editor

Post by sdh »

Sorry for opening an old thread, but it would be great if we could enter the LUA script for the device directly in domoticz, similar to Fibaro HC2.
User avatar
pipersw
Posts: 5
Joined: Thursday 29 May 2014 17:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Script editor

Post by pipersw »

+1 for a LUA text editor integrated to Domoticz.
The problem with shellinabox is that it not only allowed to edit text, but also allow ssh command and others stuff.
I prefer to use my own SSH tool for admin commands, and let only a simple text editor integrated in Domoticz for users.
I think it's more secure :P

for example: http://foicica.com/textadept/ is a lightweight text editor
Domoticz server : Raspberry + RFXCOM433 USB + Razberry
Server : Windows Home Server 2011
Weather : Oregon temperature sensor + Weather Underground
Energy: OWL119
3x plug Chacon DIO
1x Fibaro FDG-211
1x Fibaro FGWPE-101
1x Karotz with OpenKarotz firmware
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Script editor

Post by remb0 »

I was also thinking about that (when I was @ work where all ports except 80 are blocked)
But the comments in this thread are fair, the mainstrain users and options are more important.

a LUA settings page

script status versie test edit
---------------------------------------------
script1 active 1.0 check edit
script2 disabled 2.0 check edit
script3 active 0.2 check edit

options: upload script globale variables


script editor:
- velden als:
versie,
opmerking
status

- syntax checker (http://www.lua.org/demo.html)
- testen met test variablen
commodore white
Posts: 63
Joined: Sunday 14 July 2013 11:19
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Ipswich, UK
Contact:

Re: Script editor

Post by commodore white »

simonrg wrote:
In fact using Shellinabox seems to be very easy on Raspberry Pi simply two commands:

Code: Select all

sudo apt-get install shellinabox
shellinaboxd --port=4201 -t -s /:AUTH:HOME:/bin/bash
Now in a web browser http://192.168.1.111:4201 opens a shell in my web browser which allows me to modify LUA scripts.
I mostly use an android tablet to prrewardrd ogram my raspi domoticz so i thought i'd try this.

Everything went well until I typed in my raspi username and password (pi/raspberry) at which point I was rewarded by a Session Closed message.

What might I have forgotten to do?
User avatar
galadril
Posts: 828
Joined: Monday 07 September 2015 10:32
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Contact:

Re: Script editor

Post by galadril »

+1 would love a script editor within Domoticz
Solar panels of Ginlong, Omnik-Solar, Transenergy or Solarman?? Try my Android app:
https://play.google.com/store/apps/deta ... ongmonitor
alfred_j_kwak
Posts: 110
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Script editor

Post by alfred_j_kwak »

Maybe this link can go under script editor thread?

In Digital Ocean website there is guide how to use sshfs. It is possible to mount like Domoticz script folder in your programming PC and use it like a local folder.
I use Sublime Text for editing scripts and with sshfs I can edit scripts straight from /domoticz/scripts/ folder.

Link to Digital Ocean page: https://www.digitalocean.com/community/ ... s-over-ssh

Like so:
Attachments
Sublime.png
Sublime.png (25.1 KiB) Viewed 8329 times
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Script editor

Post by Dnpwwo »

I'm working on putting an editor (see https://ace.c9.io/#nav=about) into Domoticz that will handle Lua (& Python if enabled). It will have code highlighting and and collapsing.

Should be in the Beta release within a week and will need some testers. It will be backwards compatible with old file based scripts but will store new scripts in the database like Blockly does.

It will look a bit like this:
Untitled.png
Untitled.png (87.4 KiB) Viewed 8253 times
will allow users to choose their langauge and when the scripts will be called (device, time, security or uservariable).
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Script editor

Post by jvdz »

I wouldn't mind doing testing on LUA scripts, but would like to understand first why you opted to put the scripts into the database in stead of the regular file systems like it is today?
It feels like you are then totally limited to use the internal editor only, which is not something I would want for myself.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Script editor

Post by remb0 »

Very nice!! I will test it when released. When de scripts are I the db. It would be great to have extra options like.:
- version
- option to enable/disable
- export to file
- script checker: are variables valid?

Dnpwwo wrote:I'm working on putting an editor (see https://ace.c9.io/#nav=about) into Domoticz that will handle Lua (& Python if enabled). It will have code highlighting and and collapsing.

Should be in the Beta release within a week and will need some testers. It will be backwards compatible with old file based scripts but will store new scripts in the database like Blockly does.

It will look a bit like this:
Untitled.png
will allow users to choose their langauge and when the scripts will be called (device, time, security or uservariable).
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Script editor

Post by Dnpwwo »

It will be backwards compatible with old file based scripts
You don't have to use it at all if you don't want to. If you want to develop scripts outside Domoticz you can, then store the final version in the database if you want to.

Enable/disable will work for scripts the same way it does for Blockly currently.

Wasn't going to do an export because you can cut and paste directly in and out of the editor.

Might do syntax checker and 'run now' functionality later but want to get a first version merged
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Script editor

Post by tlpeter »

I agree on not putting the scripts in the database but in the folder where it belongs.
Otherwise you have two locations where such a script is.
Sometimes i copy the script out, change it and put it back for different kind of reasons.
I do like the effort being put in to this for sure.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest