Real-time solar data : azimuth, Altitude, Lux sensor... [closed]

Moderator: leecollings

Locked
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post 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
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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!
User avatar
capman
Posts: 153
Joined: Friday 12 July 2013 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

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

Post 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 ?
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post 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 3522 times
And what you says:[ and i have ]
ScreenShot198.jpg
ScreenShot198.jpg (37.29 KiB) Viewed 3522 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 3522 times
Changed my api.
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post by Derik »

And:
ScreenShot201.jpg
ScreenShot201.jpg (31 KiB) Viewed 3519 times
with this?
ScreenShot202.jpg
ScreenShot202.jpg (36.51 KiB) Viewed 3519 times
And i have:
ScreenShot203.jpg
ScreenShot203.jpg (47.83 KiB) Viewed 3519 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
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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!
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post by Derik »

@vmb

Not working :-(
Please some screendumps of your settings...
script, sensors etc,,
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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 3489 times
sensors2.jpg
sensors2.jpg (50.93 KiB) Viewed 3489 times
sensors1.jpg
sensors1.jpg (83.2 KiB) Viewed 3489 times
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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)
Attachments
JSON.rar
(9.48 KiB) Downloaded 139 times
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post 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?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
User avatar
capman
Posts: 153
Joined: Friday 12 July 2013 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

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

Post by capman »

Okee, it's working now. Replace my original json.lua file with yours.
Thanks vmb :D
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post 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..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post by Derik »

Code: Select all

 -- and customize the URL of api.wunderground around line 104 according to your country.
What do i do here..???
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
vmb
Posts: 26
Joined: Thursday 02 October 2014 14:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post 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)
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

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

Post 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....
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
trixwood

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

Post 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.... :-)
Locked

Who is online

Users browsing this forum: No registered users and 1 guest