lua without dzVents

Moderator: leecollings

Post Reply
curious
Posts: 132
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

lua without dzVents

Post by curious »

I enabled the event system for a few days now, and because of that (I think) domoticz crashes from time to time. I did turn it off for the same reason.
Now I want to start the lua scripts by crontab.

One script runs fine, but now I want to export a script from the internal script editor to a separate lua script that will be started by crontab too.
When testing that script by starting it manually however it gives errors like shown in the picture.
lua error.JPG
lua error.JPG (19.48 KiB) Viewed 690 times
Is it not just possible to copy the script from the internal editor to a separate lua script ?

The code I use works correct in when used within Domoticz (wellknown for a lot of you I suppose :D )

Code: Select all

--Windmeter data:


local sensoren = 'Buienradar_nieuw _ Wind'
local idxt = 365 --idx of the virtual temperature sensor you need to change this to your own Device IDx
local idxh = 366 --idx of the virtual humidity sensor you need to change this to your own Device IDx
local idxi = 367 --idx of the virtual pressure sensor you need to change this to your own Device IDx
local idxj = 368
local idxk = 369
local idxl = 370




commandArray = {}



if devicechanged[sensoren] then

sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues[sensoren]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
 
sWindDirectionDegrees = tonumber(sWindDirectionDegrees);
sWindDirection = (sWindDirection);
sWindSpeed = tonumber(sWindSpeed);
sWindGust = tonumber(sWindGust);
sWindTemperature = tonumber(sWindTemperature);
sWindFeel = tonumber(sWindFeel);

print("Windmeter: Winddirection (in degrees) is: " .. sWindDirectionDegrees .. " ");
print("Windmeter: Winddirection is: " .. sWindDirection .. " ");
print("Windmeter: Windspeed is: " .. sWindSpeed .. " ");
print("Windmeter: Windgust is: " .. sWindGust .. " ");
print("Windmeter: Windtemperature is: " .. sWindTemperature .. " ");
print("Windmeter: Windfeel is: " .. sWindFeel .. " ");




commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWindDirectionDegrees}
commandArray[2] = {['UpdateDevice'] = idxh .. '|0|' .. sWindDirection}
commandArray[3] = {['UpdateDevice'] = idxi .. '|0|' .. sWindSpeed}
commandArray[4] = {['UpdateDevice'] = idxj .. '|0|' .. sWindGust}
commandArray[5] = {['UpdateDevice'] = idxk .. '|0|' .. sWindTemperature}
commandArray[6] = {['UpdateDevice'] = idxl .. '|0|' .. sWindFeel}

end

return commandArray 
 
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: lua without dzVents

Post by jvdz »

curious wrote: Friday 13 October 2017 20:42 Is it not just possible to copy the script from the internal editor to a separate lua script ?
NO, Those arrays will only be available when the event systems shells the LUA script as they are build by it!
I am running LUA script since running Domoticz some 2 years now and have no issues what so ever. Running current production version.

So what exactly is the issue you have with crashing?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
curious
Posts: 132
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

Re: lua without dzVents

Post by curious »

Well, since tonight I am not sure anymore that it crashed. Perhaps it only shows that it is offline while it is still running.

Since today I get the message Browser cache refresh failed. When I check the status however domoticz is still running.
Clearing browser does not help and the offline status shows up in every browser.
When checking the console messages of google chrome it shows this :

Code: Select all

Document was loaded from Application Cache with manifest http://10.0.0.12:8080/html5.appcache
(index):1 Application Cache Checking event
(index):1 Application Cache Error event: Manifest fetch failed (6) http://10.0.0.12:8080/html5.appcache
jquery-1.12.0.min.js:4 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
send @ jquery-1.12.0.min.js:4
4jquery-1.12.0.min.js Failed to load resource: net::ERR_CONNECTION_REFUSED
send @ jquery-1.12.0.min.js:4
So I am a little lost now.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest