Search found 857 matches

by jvdz
Monday 11 December 2017 0:01
Forum: LUA
Topic: Lua script to extract data from json
Replies: 8
Views: 80

Re: Lua script to extract data from json

Just as an example how to process this JSON: This lists all occurences of maxReportWatts

Code: Select all

local jsonData = json:decode(Stringjson)
tc = #jsonData
for i = 1, tc do
	print(jsonData[i].maxReportWatts)
end
Jos
by jvdz
Sunday 10 December 2017 23:56
Forum: LUA
Topic: Lua script to extract data from json
Replies: 8
Views: 80

Re: Lua script to extract data from json

Ok, so now it is indeed a valid JSON file, but it doesn't contain the field energy_today.
What data do you want the extract from the JSON?

Jos
by jvdz
Sunday 10 December 2017 23:34
Forum: LUA
Topic: Lua script to extract data from json
Replies: 8
Views: 80

Re: Lua script to extract data from json

Iam getting an different error as it seems the JSON file you attached isn't complete:
can't parse JSON at char 1179 of: [

Could you check the data in the file?

Jos
by jvdz
Sunday 10 December 2017 23:09
Forum: LUA
Topic: Lua script to extract data from json
Replies: 8
Views: 80

Re: Lua script to extract data from json

samhh83 wrote:
Sunday 10 December 2017 22:59
This trows an error : attempt to index global 'devicechanged' (a nil value)
The shown code won't throw that error as it doesn't contain the devicechanged table.
How are you running this LUA script? Internal editor? If so, you need to change the Event type to Device in stead of All.

Jos
by jvdz
Sunday 10 December 2017 21:33
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

edwin1234 wrote:
Sunday 10 December 2017 21:11
zag door de bomen het bos niet meer ;-)
thank u very much for all your help.
Top!
Shit happens, and as stated, a computer can get into an undefined state and does need a reboot every now and then :)
Cheers,
Jos
by jvdz
Sunday 10 December 2017 20:21
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

Which version are you running?
Tried a restart of Domoticz/Raspberry? ( Sorry, I've lived my whole life with Windows and this is often a standard remedy)

Jos
by jvdz
Sunday 10 December 2017 12:05
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

So it really looks like there is a basic issue running the /home/pi/domoticz/scripts/servoscript.sh bash script from domoticz.
What do you see when you do the following command from the commandprompt?:
ls -l /home/pi/domoticz/scripts/serv*.*

Jos
by jvdz
Sunday 10 December 2017 11:30
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

The "sudo chmod +x " will only set the execute flag.
To allow everybody access you could do : "sudo chmod 777" for both files.

Jos
by jvdz
Sunday 10 December 2017 11:18
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

Another thing to check is whether the permissions are set correctly for both files!

Jos
by jvdz
Sunday 10 December 2017 11:13
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

edwin1234 wrote:
Sunday 10 December 2017 8:14
Error: Error executing script command (/usr/bin/python3). returned: -1
Are you sure you did put this in there: "script:///home/domoticz/scripts/servoscript.sh"
..and not "script:///usr/bin/python3 /home/domoticz/scripts/python/servoscript.py " like @febalci suggested?

Jos
by jvdz
Saturday 09 December 2017 20:46
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

So what happens when you have this in /home/domoticz/scripts/servoscript.sh: #!/bin/bash python3 /home/pi/domoticz/scripts/python/servoscript.py >> /var/tmp/test.log 2>&1 & exit 0 .. and you check the logfile for any feeedback? : /var/tmp/test.log Change the path for the logfile to anything your sys...
by jvdz
Saturday 09 December 2017 20:31
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

Did you set the x attribute for them to allow them to be executed?
Don't forget to add the & to the end of the command to avoid hanging the event system for the duration of the script.

Jos
by jvdz
Saturday 09 December 2017 19:44
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

No ... I mean what is the commandline you used in the Bash file that isn't working and the commandline that is working?
Also: what is the content of script: script:///home/domoticz/scripts/servoscript.sh ?

Jos
by jvdz
Saturday 09 December 2017 18:48
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

How does the commandline you want to start look exactly?
Do you use the fully qualified path for the python file?

Jos
by jvdz
Saturday 09 December 2017 18:04
Forum: Scripts [cleaning in progress]
Topic: python script to lua
Replies: 26
Views: 261

Re: python script to lua

I am doing something similar but use a bash script in the On action, which then shells another Bash script. Main reason for this approach was to avoid hanging the event system while the action was running. You could use a similar approach and shell a python script by just updating the below code. Th...
by jvdz
Saturday 09 December 2017 16:01
Forum: Bugs and Problems
Topic: Energy consumption incorrectly computed by Domoticz?
Replies: 6
Views: 152

Re: Energy consumption incorrectly computed by Domoticz?

Are the updates send exactly after 60 seconds or could it be that it slips a couple of seconds with each update?
I can imagine this causes this issue.

Jos
by jvdz
Saturday 09 December 2017 13:50
Forum: RFLink Transceiver
Topic: Lua virtual device thermostat device change
Replies: 7
Views: 85

Re: Lua virtual device thermostat device change

The devicechanged table will contain the device(s) changed and their new value while you compare them to true. try: - Thermostat setpoint local WNKT = '1 thermostat' local HSLPT = '2 Thermostat' local KLNKT = '3 thermostat' --Maxscript (Virtual switch) local Max = "Maxscript" commandArray = {} if (d...
by jvdz
Saturday 09 December 2017 13:20
Forum: RFLink Transceiver
Topic: Lua virtual device thermostat device change
Replies: 7
Views: 85

Re: Lua virtual device thermostat device change

This would be a good point to start in case you want to write LUA scripts: https://www.domoticz.com/wiki/Events

Jos
by jvdz
Saturday 09 December 2017 12:16
Forum: RFLink Transceiver
Topic: Lua virtual device thermostat device change
Replies: 7
Views: 85

Re: Lua virtual device thermostat device change

That should work fine. Did you actually give it a try to see what happens as the shown code doesn't have the proper syntax?

Jos
by jvdz
Friday 08 December 2017 10:27
Forum: Design, usability and languages
Topic: framb0ise v2 - awesome new dashboard!
Replies: 180
Views: 16397

Re: framb0ise v2 - awesome new dashboard!

Hi Rob, do you have any ROOMPLANs defined in Domoticz with devices in it as those are used by franb0ise?

Jos