Hope you can take that beer now
Real-time solar data : azimuth, Altitude, Lux sensor... [closed]
Moderator: leecollings
-
trixwood
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
And would you please censor you long and latitude... 
Hope you can take that beer now
Hope you can take that beer now
-
Derik
- Posts: 1605
- 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...
I did changetrixwood wrote:And would you please censor you long and latitude...
Hope you can take that beer now
The beer will i send to you ...???
I drink to much .. with al this higher math..
I do have now 2 working sensors..
And a lux that is i think work tomorrow ... [ for me is the LUX the sensor i need .. ]
And wtf doe i need with the baro etc etc.??
And the other 2 what can i doe with these..
xxx
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...
You can use the sun position to have finer time tunning in your scripts...
Check out:
http://www.timeanddate.com/astronomy/di ... light.html
so instead of sunrise and sunfall you have way more options to choose from... which can be handy for different light levels when it gets dark, and other usefull stuff!
sun altitude...
Check out:
http://www.timeanddate.com/astronomy/di ... light.html
so instead of sunrise and sunfall you have way more options to choose from... which can be handy for different light levels when it gets dark, and other usefull stuff!
sun altitude...
-
Derik
- Posts: 1605
- 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...
only what have the pressure to do with it?
By the way THANKS!!! They work all three...
By the way THANKS!!! They work all three...
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...
altitude, 4 degrees... It's almost nautical twilight... 
still living in civil twilight
uhmm.. or is it the other way around... for you... (timezones
yes, i think so, -18 till nautical -6, -6 till 0 is civil twilight... so now it day at least at your end of the planet
For me it's dinner time! Have a good day!
still living in civil twilight
uhmm.. or is it the other way around... for you... (timezones
yes, i think so, -18 till nautical -6, -6 till 0 is civil twilight... so now it day at least at your end of the planet
For me it's dinner time! Have a good day!
-
Derik
- Posts: 1605
- 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...
trixwood wrote:altitude, 4 degrees... It's almost nautical twilight...
still living in civil twilight
uhmm.. or is it the other way around... for you... (timezones
yes, i think so, -18 till nautical -6, -6 till 0 is civil twilight... so now it day at least at your end of the planet![]()
For me it's dinner time! Have a good day!
MMM is there a way where i can check this data??
Or how do i now for sure that my settings are coerrect?
Stil, why pressure in this settings,,
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
-
confucius
- Posts: 5
- Joined: Saturday 09 January 2016 2:15
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
So, not sure if this was raised already, but all is working fine for me except one small detail. The way the 5 min interval is implemented does not seem to work very well.
I'm definitely not a lua guru, but from what Iunderstand in the code is that the time.min%5 statement ensures the code is only run every 5th minute interval (which is fine). The problem seems to be that there's nothing that ensures the script only runs once within that minute, which yesterday resulted in me recieving a note from wu that I had exceeded the 100-API calls per minute mark.
Am I missing some kind of crucial setup step, or is this something that should be addressed in the code?
I'm definitely not a lua guru, but from what Iunderstand in the code is that the time.min%5 statement ensures the code is only run every 5th minute interval (which is fine). The problem seems to be that there's nothing that ensures the script only runs once within that minute, which yesterday resulted in me recieving a note from wu that I had exceeded the 100-API calls per minute mark.
Am I missing some kind of crucial setup step, or is this something that should be addressed in the code?
- jvdz
- Posts: 2441
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
How did you implement the script?
When you either name it as script_time_*.lua when using loose files or when using the internal editor, you need to change the dropdownbox under LUA from "ALL" to "Time". This way you ensure the script only runs once a minute on the minute.
Jos
When you either name it as script_time_*.lua when using loose files or when using the internal editor, you need to change the dropdownbox under LUA from "ALL" to "Time". This way you ensure the script only runs once a minute on the minute.
Jos
-
trixwood
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
If you add normal domoticz weatherunderground hardware, and remove the underground part from the script, replacing it with
where 'Weather TempHumBaro' is your sensor name of the weatherunderground.
you probably would not run into api calls exceeded. You can even run it every minute, since the (in my case inaccurate) cloud provider can be called as many times as you want. (i have seen no problems there). The creator of the script (or somebody should update the wiki and add this info)... now you or getting the same results twice (if you already have weatherunderground hardware) or you could have extra sensors to begin with... (if you do not use the weatherunderground hardware already)....
Code: Select all
temp, hum, uv, pres = otherdevices_svalues['Weather TempHumBaro']:match("([^;]+);([^;]+);([^;]+);([^;]+)")
relativePressure = tonumber(pres)
you probably would not run into api calls exceeded. You can even run it every minute, since the (in my case inaccurate) cloud provider can be called as many times as you want. (i have seen no problems there). The creator of the script (or somebody should update the wiki and add this info)... now you or getting the same results twice (if you already have weatherunderground hardware) or you could have extra sensors to begin with... (if you do not use the weatherunderground hardware already)....
-
confucius
- Posts: 5
- Joined: Saturday 09 January 2016 2:15
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
Yep that 'time' setting did the trick! Thanks guys!
It does seem more people have this issue, in one of the screens shots above the same issue appears to occur.
Verzonden vanaf mijn iPad met Tapatalk
It does seem more people have this issue, in one of the screens shots above the same issue appears to occur.
Verzonden vanaf mijn iPad met Tapatalk
-
Derik
- Posts: 1605
- 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...
mmm
Please some post a clean and working script...
With all the option..
I do not understand a f&^%&^cking thing of all this higher mat..
Only i have a great option for my sunscreens..
Thanks!!!!
Please some post a clean and working script...
With all the option..
I do not understand a f&^%&^cking thing of all this higher mat..
Only i have a great option for my sunscreens..
Thanks!!!!
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
-
Nautilus
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
Recently seeing a lot of this in the log:
Seems to be related to the cloud layer thing. This row gives the error:
It happens when the url is not returning even the "Status: 500 Fecha final anterior a la incial" but basically nothing. What would be the best practice to take this into account?
edit: this at least works:
change is adding and synop ~= '' to the first if-statement
Code: Select all
2016-09-02 08:20:03.260 Error: EventSystem: in SunPositions: [string "-- Variables to customize -------------------..."]:137: bad argument #1 to 'gsub' (string expected, got nil)edit: this at least works:
Code: Select all
if string.find(synop,"Status: 500") == nil and synop ~= ''
then
rslt = split(synop,",")
CodeStation = rslt[1]
rslt = split(synop, " "..CodeStation.. " ")
Trame = string.gsub(rslt[2], "=", "")
Trame = CodeStation .." ".. Trame
rslt = split(Trame, " ")
Octa = string.sub(rslt[3], 1, 1) -- 3rd char is the cloud layer. 0=no cloud , 1-8= cloudy from 1 to 8 max , 9 =Fog , / = no data
if Octa == "/" then -- not defined ? take the previous value
Octa = uservariables['octa']
elseif Octa == "9" then
Octa = 8
end
else
Octa = uservariables['octa']
end
-
xces
- Posts: 39
- Joined: Thursday 05 February 2015 9:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
So i am wondering here. I have activated the script since yesterday. I get different values compared to my Fibaro sensor, and i mean A LOT of deviation.
Here are some graphs;
Fibaro (battery powered, hanging at my front door, pointing downwards to limit false movements), the 22 lux is my front door light by the way.

Calculated lux (which has a nice curve on it)

Look at the min/max values and you'll see what i'm talking about. Fibaro goes to 1000, the calculated lux goes to 10k (and no it is not linear). So either the Fibaro is really crap at lux calculation, the script is a better representation or it is somewhere in the middle. I don't need the exact lux values but i do need to have something 'usefull'. My living room lights switched on at 18:23 when there was about 544 lux, which on that side is in line with what the script says (local arbitraryTwilightLux=4.74 -- W/m² egal 600 Lux). So.. what do you guys say about this?
p.s. i have this blockly script, any improvements on that are welcome.

I first had the time parameter in it, like this; to prevent it during the day and cloudy weather to turn on..

But i might want to switch that to "if lux < 600 AND ItHasBeenFor10Minutes" or something. No idea on how to implement that...
As a last question, can't we make the "Sun Azimuth" and "Sun Altitude" also 'user variables' instead of devices?
Here are some graphs;
Fibaro (battery powered, hanging at my front door, pointing downwards to limit false movements), the 22 lux is my front door light by the way.

Calculated lux (which has a nice curve on it)

Look at the min/max values and you'll see what i'm talking about. Fibaro goes to 1000, the calculated lux goes to 10k (and no it is not linear). So either the Fibaro is really crap at lux calculation, the script is a better representation or it is somewhere in the middle. I don't need the exact lux values but i do need to have something 'usefull'. My living room lights switched on at 18:23 when there was about 544 lux, which on that side is in line with what the script says (local arbitraryTwilightLux=4.74 -- W/m² egal 600 Lux). So.. what do you guys say about this?
p.s. i have this blockly script, any improvements on that are welcome.

I first had the time parameter in it, like this; to prevent it during the day and cloudy weather to turn on..

But i might want to switch that to "if lux < 600 AND ItHasBeenFor10Minutes" or something. No idea on how to implement that...
As a last question, can't we make the "Sun Azimuth" and "Sun Altitude" also 'user variables' instead of devices?
-
ArnaudStrasbourg
- Posts: 4
- Joined: Sunday 23 October 2016 2:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
Hi all,
I tried this code but it return an error : Files\Domoticz\scripts\lua\script_time_SolarSensor.lua:13: syntax error near 'local'
This is my code (no deap change...)
Thank you for a idea.
Arno.
I tried this code but it return an error : Files\Domoticz\scripts\lua\script_time_SolarSensor.lua:13: syntax error near 'local'
This is my code (no deap change...)
Code: Select all
script_time_SolarSensor.lua --[[ Virtual Lux sensor and other real-time solar data
--~/domoticz/scripts/lua/script_time_SolarSensor.lua
-- Autors ----------------------------------------------------------------
V1.0 - Sébastien Joly - Great original work
V1.1 - Neutrino - Adaptation to Domoticz
V1.2 - Jmleglise - An acceptable approximation of the lux below 1° altitude for Dawn and dusk + translation + several changes to be more userfriendly.
V1.3 - Jmleglise - keep the time of black night in lasptUpdate
]]--
-- Variables to customize ------------------------------------------------
local city = "Paris" -- Your city for Wunderground API <--- line 13 !!
local countryCode = "FR" -- Your country code for Wunderground API
local idxLux ='53' -- Your virtual Lux Device ID
local idxSolarAzimuth ='56' -- Your virtual Azimuth Device ID
local idxSolarAltitude ='55' -- Your virtual Solar Altitude Device ID
local idxUserVarOcta='1' -- Your user variable ID , named octa
local wuAPIkey = "08c125fa719956f9" -- Your Weather Underground API Key
local latitude = 48.575875 -- your home
local longitude = 7.731194 -- your home
local altitude = 141 -- Your home altitude : run once in debug = 1 to found your altitude in Log and write it here
local WMOID = '07190' -- 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 ------------------------------------------
function leapYear(year)
return year%4==0 and (year%100~=0 or year%400==0)
end
....
Arno.
-
BakSeeDaa
- Posts: 485
- Joined: Thursday 17 September 2015 10:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
There is a problem at the first line. Change it toArnaudStrasbourg wrote:I tried this code but it return an error : Files\Domoticz\scripts\lua\script_time_SolarSensor.lua:13: syntax error near 'local'
Code: Select all
--[[ Virtual Lux sensor and other real-time solar data-
BakSeeDaa
- Posts: 485
- Joined: Thursday 17 September 2015 10:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
This problem has probably been mentioned before...
I have some old scripts that is reacting to the change of value of my lux sensor.
The 'Lux' device changes frequently by your script but I noticed that my script above never triggered upon the change of the 'Lux' device.
However if I change the following code in script_time_SolarSensor.lua that is used to update the 'Lux' device
from:
to:
and add this to the variables
It will work just fine. Now changes to the 'Lux' device can be triggered in my other scripts. I suggest to change that in the script_time_SolarSensor.lua code.
I would also suggest to change the way of counting index array items so that the example code
can be simplified to just
(it must be changed in all places of the script at the same time)
It would make the script less prone to errors if forgetting to manually add to the 'indexArray' local variable.
Cheers!
I have some old scripts that is reacting to the change of value of my lux sensor.
Code: Select all
if ((devicechanged['Lux']) then
...
endHowever if I change the following code in script_time_SolarSensor.lua that is used to update the 'Lux' device
from:
Code: Select all
commandArray[indexArray] = {['UpdateDevice'] = idxLux..'|0|'..tostring(round(weightedLux,0))}
Code: Select all
commandArray[indexArray]={['OpenURL']="http://"..localhost.."/json.htm?type=command¶m=udevice&idx="..idxLux.."&nvalue=0&svalue="..tostring(round(weightedLux,0)) }Code: Select all
local localhost = '127.0.0.1:8080'I would also suggest to change the way of counting index array items so that the example code
Code: Select all
commandArray[indexArray] = {['Variable:octa'] = tostring(Octa)}
indexArray=indexArray+1Code: Select all
commandArray[#commandArray + 1] = {['Variable:octa'] = tostring(Octa)}It would make the script less prone to errors if forgetting to manually add to the 'indexArray' local variable.
Cheers!
-
jmleglise
- Posts: 192
- Joined: Monday 12 January 2015 23:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: FRANCE
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
Hi,you're right, BakSeeDaa,
I have reported this limitation of the custom sensor / devicechanged in the bug section.You could insist to priorize it ...
http://www.domoticz.com/forum/viewtopic ... 726#p93726
And thank you for the "#commandArray + 1" trick.
I will update the source code,
I have reported this limitation of the custom sensor / devicechanged in the bug section.You could insist to priorize it ...
http://www.domoticz.com/forum/viewtopic ... 726#p93726
And thank you for the "#commandArray + 1" trick.
I will update the source code,
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
-
BakSeeDaa
- Posts: 485
- Joined: Thursday 17 September 2015 10:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
Hi @jmleglise
I do not understand the intention of the following piece of code:
WMOID has already been globally declared.
The local variables WMOID has its scope limited to the block where its declared. If I'm not wrong, the piece of code above never does nothing.
I do not understand the intention of the following piece of code:
Code: Select all
if (DEBUG == 1) then
local WMOID = jsonLocation.current_observation.display_location.wmo
endThe local variables WMOID has its scope limited to the block where its declared. If I'm not wrong, the piece of code above never does nothing.
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
@BakSeeDaa
May be mistaken (and jmleglise may correct me), but the lines you quote are overriding the earlier (default) declaration of WMOID at the start of the script. For Debug=1 these 3 lines (and several other lines) provide an automatic adjustment within the script [for
lazy users] based on the geographical information coming from
For the less lazy users, knowing their exact geographical position, it is quite easy (before tuning the script) to once make an url-call to ogimet with the accurate location-info to get the best fitting WMOID for insertion in the declarations: then no need for the related calls in the script to WUnderground and subsequently to ogimet, which anyway might result in rather ambiguous information.
Earlier hinted in this thread with response from jmleglise: http://www.domoticz.com/forum/viewtopic ... =60#p93098
May be mistaken (and jmleglise may correct me), but the lines you quote are overriding the earlier (default) declaration of WMOID at the start of the script. For Debug=1 these 3 lines (and several other lines) provide an automatic adjustment within the script [for
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)Earlier hinted in this thread with response from jmleglise: http://www.domoticz.com/forum/viewtopic ... =60#p93098
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
-
ArnaudStrasbourg
- Posts: 4
- Joined: Sunday 23 October 2016 2:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Real-time solar data : azimuth, Altitude, Lux sensor...
Thank you BakSeeDaa,BakSeeDaa wrote:There is a problem at the first line. Change it toArnaudStrasbourg wrote:I tried this code but it return an error : Files\Domoticz\scripts\lua\script_time_SolarSensor.lua:13: syntax error near 'local'Code: Select all
--[[ Virtual Lux sensor and other real-time solar data
In fact, I copied the code located in the wiki. It isn't up-to-date.
Now, I have an other problem :
Domoticz can't read my location.
This is my parametres in Lua :
local wuAPIkey = "0xxxxxxx719956f9" -- code hide
local latitude = 48.575875
local longitude = 7.731194
local altitude = 141
local city = "Strasbourg"
local countryCode="FR"
Domoticz return : 2016-10-25 11:45:00.228 Error: EventSystem: in C:\Program Files\Domoticz\scripts\lua\script_time_SolarSensor.lua: ...m Files\Domoticz\scripts\lua\script_time_SolarSensor.lua:80: attempt to index local 'jsonLocation' (a nil value)
So I thought that it can't read my datas. I tried in my browser : http://api.wunderground.com/api/0xxxxxx ... bourg.json
That was ok. Return to me :
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
}
, "current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"Strasbourg, France",
"city":"Strasbourg",
"state":"67",
"state_name":"France",
"country":"FR",
"country_iso3166":"FR",
"zip":"00000",
"magic":"1",
"wmo":"07190",
"latitude":"48.54999924",
"longitude":"7.63000011",
"elevation":"153.0"
Etc...
So, I add a line in lua to see the data.
local location = config:read('*all')
print (location) <---- This line
config:close()
And the result is :
2016-10-25 11:55:00.885 LUA:
EMPTY !!!
Does anyone could tell me where is my mistake ? Thank you so much in advance.
I'm on the Domoticz windows version (V3.5818)
@rn0
Who is online
Users browsing this forum: No registered users and 1 guest