Page 5 of 13

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Saturday 20 August 2016 12:20
by vmb
@derik: whats your question?

Can also send me a pm in Dutch. Perhaps I can help you, although the wiki is very clear. Only problem I encountered was to put JSON.lua in scriptfolder on my Pi3. After that all went right.

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Saturday 20 August 2016 12:55
by Derik
I did all the things in the wiki.
Only my script is not working.
I did not get the:

Code: Select all

Your home altitude : run once in debug = 1 to found your altitude in Log and write it here
And my log error:

Code: Select all

2016-08-20 12:55:00.557 Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_time_SolarSensor.lua: .../linaro/domoticz/scripts/lua/script_time_SolarSensor.lua:56: attempt to call a nil value

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Saturday 20 August 2016 14:26
by vmb
@Derik:

I noticed three different things in your setup:

- The names of the custom sensors should be :"Sun Azimuth" and "Sun Altitude" Exactly like in the wiki.
- In the box of these custom sensors (click on "aanpassen") Type at the field "Aslabel" the word 'degrees' at both custom sensors.
- The name of the Weather Underground location voor Nijmegen should be "Nijmegen" or try "Molukkenstraat" You used the Weather Underground codename of the station in your script. During installation I got the same failure message. Once I changed the name in the script, all went right.
(Molukkenstraat (INIJMEGE14)

Give it a try!

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Saturday 20 August 2016 16:40
by capman
Got the folowing error in my log
2016-08-20 16:35:00.788 Error: EventSystem: in /usr/local/domoticz/var/scripts/lua/script_time_SolarSensor.lua: /usr/local/domoticz/var/scripts/lua/json.lua:352: bad argument #1 to 'len' (string expected, got table)

A used the last beta version (v3.5523). And it runs on a synology , so a changed the line for json.lua in the script to the correct path.
Any idea ?

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Saturday 20 August 2016 21:07
by Derik
@ VMB [ From Nijmegen?? :D :D :D ]

I did what you say..
Only the wiki has some errors i think :cry:
The Wiki:
ScreenShot199.jpg
ScreenShot199.jpg (60.13 KiB) Viewed 3532 times
And what you says:[ and i have ]
ScreenShot198.jpg
ScreenShot198.jpg (37.29 KiB) Viewed 3532 times
Only i think i don not now how i run in debug for 1 time:

Code: Select all

 local altitude = 27              -- Your home altitude : run once in debug = 1 to found your altitude in Log and write it here
       local WMOID = '07145'    -- Your nearest SYNOP Station for ogimet (to get Cloud layer). Run once with debug=1 to get it in the log. (or, better, choose it there : http://www.ogimet.com/gsynop_nav.phtml.en )
       local DEBUG = 0             -- 0 , 1 for domoticz log , 2 for file log
While i got this setting:
ScreenShot200.jpg
ScreenShot200.jpg (67.6 KiB) Viewed 3532 times
Changed my api.

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Saturday 20 August 2016 21:17
by Derik
And:
ScreenShot201.jpg
ScreenShot201.jpg (31 KiB) Viewed 3529 times
with this?
ScreenShot202.jpg
ScreenShot202.jpg (36.51 KiB) Viewed 3529 times
And i have:
ScreenShot203.jpg
ScreenShot203.jpg (47.83 KiB) Viewed 3529 times
Changed something.
Only the error:

Code: Select all

2016-08-20 21:15:00.225 Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_time_SolarSensor.lua: .../linaro/domoticz/scripts/lua/script_time_SolarSensor.lua:56: attempt to call a nil value
Is there

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 9:28
by vmb
@Derik

No, not from Nijmegen. From Alblasserwaard. :D

Guess you checked the Idx-numbers from all the sensors?

Only thing I can think of is changing "Molukkenstraat" in "Nijmegen". Perhaps you tried that already? Check Weather Underground for stations/names nearby.

Debug can be found in Domoticz-log when you set is to value '1'.

You did put JSON.lua in script directory?

Hope this helps, because my knowledge of this script is coming to an end.

Succes!

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 10:38
by Derik
@vmb

Not working :-(
Please some screendumps of your settings...
script, sensors etc,,

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 11:21
by vmb
@Derik,

Here is my script; only changed the WU-api

-- Variables to customize ------------------------------------------------
local city = "Liesveld" -- Your city for Wunderground API
local countryCode = "NL" -- Your country code for Wunderground API
local idxLux ='428' -- Your virtual Lux Device ID
local idxSolarAzimuth ='429' -- Your virtual Azimuth Device ID
local idxSolarAltitude ='430' -- Your virtual Solar Altitude Device ID
local idxUserVarOcta='7' -- Your user variable ID , named octa
local wuAPIkey = "6e4404XXX" -- Your Weather Underground API Key
local latitude = 51.885823 -- your home
local longitude = 4.662413 -- your home
local altitude = -2 -- Your home altitude : run once in debug = 1 to found your altitude in Log and write it here
local WMOID = '06344' -- Your nearest SYNOP Station for ogimet (to get Cloud layer). Run once with debug=1 to get it in the log. (or, better, choose it there : http://www.ogimet.com/gsynop_nav.phtml.en )
local DEBUG = 1 -- 0 , 1 for domoticz log , 2 for file log
-- and customize the URL of api.wunderground around line 104 according to your country.

-- Below , edit at your own risk ------------------------------------------
variabele.jpg
variabele.jpg (35.12 KiB) Viewed 3499 times
sensors2.jpg
sensors2.jpg (50.93 KiB) Viewed 3499 times
sensors1.jpg
sensors1.jpg (83.2 KiB) Viewed 3499 times

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 11:25
by vmb
And here is my JSON.lua in a rar file. Unrar it and place it in script-dir (same dir as where Solar script is placed)

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 12:12
by Derik
mmm
How do you come to otca value 8?
And do i need to rename the JSON.lua to script_time_JSON.lua?

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 12:13
by capman
Okee, it's working now. Replace my original json.lua file with yours.
Thanks vmb :D

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 12:54
by vmb
Derik wrote:mmm
How do you come to otca value 8?
And do i need to rename the JSON.lua to script_time_JSON.lua?
My octa is 7 because I use other variables. Thats why this is number 7.

Json extract from rarfile. Leave name as it is.

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 12:55
by vmb
capman wrote:Okee, it's working now. Replace my original json.lua file with yours.
Thanks vmb :D
Great nice to hear this helped you out.

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 13:32
by Derik
mmm
You guys run on Windows???

I see:

Code: Select all

    json = (loadfile "/home/linaro/domoticz/scripts/lua/JSON.lua")()  -- For Linux
      -- json = (loadfile "D:\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
Change this to my cubieboard.


And this:

Code: Select all

  local config=assert(io.popen('curl http://api.wunderground.com/api/'..f4cf6d9992844b..'/conditions/q/'..NL..'/'..Nijmegen..'.json'))  -- customize here !!
Changed here my things

And here:

Code: Select all

--os.execute('curl "http://192.168.5.70:8080/json.htm?type=command&param=updateuservariable&idx='..idxUserVarOcta..'&vname=octa&vtype=0&vvalue='..tostring(Octa)..'"')
I removed the -- and set my Cubieboard IP:port


And here:

Code: Select all

 cmd='curl "http://192.168.5.70:8080/json.htm?type=command&param=udevice&idx='..idxLux..'&svalue='..tostring(round(weightedLux,0))..'"'
Removed the -- and set my IP:Port

Only:
my dummy's are red..

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 13:38
by Derik

Code: Select all

 -- and customize the URL of api.wunderground around line 104 according to your country.
What do i do here..???

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 13:52
by vmb
Derik, I'm running on a Pi3.

I only changed the custumizable lines in the script. Nothing else, not even around line 104.

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 14:36
by Derik
please your total script without the api...

going creazy here..

Other error:

Code: Select all

2016-08-21 14:30:05.265 Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_time_SolarSensor.lua: .../linaro/domoticz/scripts/lua/script_time_SolarSensor.lua:97: attempt to perform arithmetic on global 'relativePressure' (a nil value)
2016-08-21 14:30:01.877 (D.M.: RFXcomE) Wind (D.M.: Wind)

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 14:37
by Derik
i am not stupid...
Think there is something more wrong then my stupid actions..
Wiki step by step..
And no luck...
Please update the wiki so thing are correct....

Re: Real-time solar data : azimuth, Altitude, Lux sensor...

Posted: Sunday 21 August 2016 17:05
by trixwood
From the original wiki

Code: Select all

  --  API Wunderground
       local config=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/conditions/q/'..countryCode..'/'..city..'.json'))
       local location = config:read('*all')
       config:close()
       local jsonLocation = json:decode(location)
       if( DEBUG == 1) then
          local latitude = jsonLocation.current_observation.display_location.latitude
          local longitude = jsonLocation.current_observation.display_location.longitude
          local altitude = jsonLocation.current_observation.display_location.elevation
          print('Lat: '..latitude..'Long: '..longitude..'Alt: '..altitude)
       end
       relativePressure = jsonLocation.current_observation.pressure_mb   -- if you have an another way to get the Pressure, (local barometer ...) then you may optimize the script and avoid the call to api.wunderground)
  
without weathe underground you need to repalce that with:

Code: Select all

relativePressure = 1012
or read it from a pressure sensor...

That yould fix your nil... now I am also stuck on the cloud coverage not coming in.... :-)