Page 2 of 4
Re: Moon phase
Posted: Thursday 27 October 2016 7:13
by Derik
@ wizjos,
Thanks for the support
I do not understand the uservariable..
Is this correct?

- ScreenShot080.jpg (60.95 KiB) Viewed 3678 times
Or what type do i need?
And this is ok?

- ScreenShot081.jpg (91.85 KiB) Viewed 3678 times
Re: Moon phase
Posted: Thursday 27 October 2016 10:19
by wizjos
Derik wrote:@ wizjos,
Thanks for the support
I do not understand the uservariable..
Is this correct?
Or what type do i need?
It looks OK to me (except that my uservar is of type Time).
The uservar is a helper in determining if an update from WU is allowed. WU only lets you poll 10 times in an hour. I found that the script was running too many times in an hour. So with some help from the wiki (
http://www.domoticz.com/wiki/Smart_Lua_ ... _Light_Off) I made a check that, when WU has been polled, updates the uservar with the current time (again, this is purely cosmetic).
By updating the uservar the 'lastupdated' property of this uservar is set. This is a Domoticz internal property. (see line 74:
commandArray['Variable:'..checkvar]=time.hour..":"..time.min). Each time the value of the uservar changes this property is set by Domoticz to the current date and time (See the column 'Laatste aanpassing' in your picture).
When the script runs again this 'lastupdated' property is checked (line 60:
if (may_update(checkvar,checktime)==true) ).
The function may_update checks the difference between the current time and the time the uservar was last updated. If this difference is 3600 seconds the script allows an other update.
I see you've created a uservar of type Text and set the value to 3600. That's OK, but the value 3600 is not important...
Derik wrote:And this is ok?
As far as I can see it is. Be a bit more carefull with displaying your API key by the way!
I hope this helps!
Re: Moon phase
Posted: Thursday 27 October 2016 14:26
by alexsh1
wizjos wrote:alexsh1 wrote:Good work @ wizjos!
Is your moon icon changing according to the moon phase? Very nice - now I'd like to implement it too

I can confirm it is

Can you enlighten me please? How did you do that? I must admit I am a complete noob when it comes to interface and icons in Domoticz.
Re: Moon phase
Posted: Thursday 27 October 2016 22:27
by Derik
mmm Not working...

- ScreenShot082.jpg (62.74 KiB) Viewed 3648 times
What can be the dombo error /mistake that i make?
Re: Moon phase
Posted: Saturday 29 October 2016 9:30
by Derik
got him:

- ScreenShot083.jpg (62.39 KiB) Viewed 3634 times
shame... did not not have activated the srcipt funtion:

- ScreenShot084.jpg (16.25 KiB) Viewed 3634 times
Only i think i changed the rise and set, is that correct??

- ScreenShot085.jpg (13.64 KiB) Viewed 3634 times
And will you please tell me how you make the changing button with a moon icon...
Re: Moon phase
Posted: Saturday 29 October 2016 9:51
by LouiS22
Brillinat, just two questions:
1. does anyone have the neat moon icon package?
2. according to the log the scripts runs in every minute. Is that normal? (I've not changed the 3600 value, so it's a bit odd for me).
Re: Moon phase
Posted: Saturday 29 October 2016 9:54
by Derik
runs every minute ..
Because it is a lua time script...
should be great when this can be adjustable
Re: Moon phase
Posted: Saturday 29 October 2016 10:03
by Derik
Should it not be better/nicer to us for rise and set custom sensors, with icons?
Rise:
https://www.google.nl/search?q=moonrise ... 0Q_AUIBigB
Set:
https://www.google.nl/search?q=moonrise ... &q=moonset
I cannot make this, it is just a idea
Re: Moon phase
Posted: Saturday 29 October 2016 19:52
by Derik
get a warning from wu..

- ScreenShot086.jpg (30.26 KiB) Viewed 3606 times
Re: Moon phase
Posted: Saturday 29 October 2016 22:09
by Derik
other error:
Code: Select all
2016-10-29 22:00:00.906 LUA: Moonrise: 6:46
2016-10-29 22:00:00.906 LUA: Moonset: 18:08
2016-10-29 22:00:00.906 LUA: Percent: 1%
2016-10-29 22:00:00.906 LUA: Age: 29
2016-10-29 22:00:10.311 Error: EventSystem: Warning!, lua script /home/pi/domoticz/scripts/lua/script_time_maan.lua has been running for more than 10 seconds
2016-10-29 22:00:02.892 (D.M.: RFLink) Temp (OregonV1)
2016-10-29 22:00:15.721 Hardware Monitor: Fetching data (System sensors)
Re: Moon phase
Posted: Sunday 30 October 2016 11:22
by LouiS22
Derik wrote:get a warning from wu..
ScreenShot086.jpg
That's why I tried to refer with my post above. IMHO the script is buggy in a way as it shouldn't run in every minute - that's 60 request from WU in an hour.
Re: Moon phase
Posted: Sunday 30 October 2016 12:43
by Derik
Perhaps someonebcab make this script working as a lua with a crontab.... In steat op lua time
Re: Moon phase
Posted: Sunday 30 October 2016 23:38
by alexsh1
LouiS22 wrote:Brillinat, just two questions:
2. according to the log the scripts runs in every minute. Is that normal? (I've not changed the 3600 value, so it's a bit odd for me).
You have to set it up according to your needs. Just think - why would need to know a moon phase every minute? I have my script (above) running every 10 minutes or so. It generates only 6 requests per hour or 144 per day. I think running it one an hour would not hurt either.
Re: Moon phase
Posted: Sunday 30 October 2016 23:39
by alexsh1
Derik wrote:other error:
Code: Select all
2016-10-29 22:00:00.906 LUA: Moonrise: 6:46
2016-10-29 22:00:00.906 LUA: Moonset: 18:08
2016-10-29 22:00:00.906 LUA: Percent: 1%
2016-10-29 22:00:00.906 LUA: Age: 29
2016-10-29 22:00:10.311 Error: EventSystem: Warning!, lua script /home/pi/domoticz/scripts/lua/script_time_maan.lua has been running for more than 10 seconds
2016-10-29 22:00:02.892 (D.M.: RFLink) Temp (OregonV1)
2016-10-29 22:00:15.721 Hardware Monitor: Fetching data (System sensors)
This is not a bug, but happens occasionally due to internet connection issue or a delayed reply from the weather server.
Re: Moon phase
Posted: Monday 31 October 2016 7:18
by Derik
dear i did set time to 4800 only i still get a warning..:

- ScreenShot092.jpg (56.32 KiB) Viewed 3550 times

- ScreenShot091.jpg (34.94 KiB) Viewed 3550 times
Or can i set the time of the lua script set to a other time to?
Re: Moon phase
Posted: Monday 31 October 2016 18:03
by Derik
Strange thing happend
I did not make a change..:

- ScreenShot094.jpg (105.27 KiB) Viewed 3537 times
Only the script is not working after a update from yesterday...
edit:
My error:
Code: Select all
2016-10-31 19:03:00.797 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_maan.lua: /home/pi/domoticz/scripts/lua/script_time_maan.lua:148: attempt to concatenate global 'moonPhaseIcon' (a nil value)
2016-10-31 19:04:00.519 Error: Webserver: File '/images/test.png': No such file or directory (2)
2016-10-31 19:04:00.980 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_maan.lua: /home/pi/domoticz/scripts/lua/script_time_maan.lua:148: attempt to concatenate global 'moonPhaseIcon' (a nil value)
2016-10-31 19:05:00.545 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_maan.lua: /home/pi/domoticz/scripts/lua/script_time_maan.lua:148: attempt to concatenate global 'moonPhaseIcon' (a nil value)
2016-10-31 19:06:00.916 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_maan.lua: /home/pi/domoticz/scripts/lua/script_time_maan.lua:148: attempt to concatenate global 'moonPhaseIcon' (a nil value)
2016-10-31 19:07:01.019 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_maan.lua: /home/pi/domoticz/scripts/lua/script_time_maan.lua:148: attempt to concatenate global 'moonPhaseIcon' (a nil value)
2016-10-31 19:08:00.677 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_maan.lua: /home/pi/domoticz/scripts/lua/script_time_maan.lua:148: attempt to concatenate global 'moonPhaseIcon' (a nil value)
Re: Moon phase
Posted: Tuesday 01 November 2016 23:02
by Derik
did make no change to anything
Only a update..

- ScreenShot102.jpg (73.51 KiB) Viewed 3522 times
working again...
Only in the log errors..

- ScreenShot101.jpg (138.58 KiB) Viewed 3522 times
...
Re: Moon phase
Posted: Wednesday 02 November 2016 0:49
by alexsh1
Derik wrote:
Only the script is not working after a update from yesterday...
Version 3.5837 (October 30th 2016)
- Fixed: Blockly/Lua, FOR and RANDOM are now again in minutes
Additionally, please see this
http://domoticz.com/forum/viewtopic.php?f=3&t=13942
Some people experience issues with the latest beta
Re: Moon phase
Posted: Monday 12 December 2016 15:45
by Derik
mmm'
The link to the other forum is not working..
Still my calls from wu are not enough...
Round 16.00 are my calls gone...
Is there a solution to make the calls not every minute, but 2 or 3 minutes?
Love this option
and the Moon picto's??
Re: Moon phase
Posted: Tuesday 20 December 2016 21:33
by cyberclwn
Derik wrote:
Only in the log errors..
ScreenShot101.jpg
I just tried use this script, and i almost got it working but i also got the error:
Code: Select all
EventSystem: in /home/pi/domoticz/scripts/lua/script_time_moon.lua: /home/pi/domoticz/scripts/lua/script_time_moon.lua:82: attempt to concatenate global 'moonriseMinute' (a nil value).
And i guess it is because the reply i get from WU doesn't contain the moonrise information:
Code: Select all
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"astronomy": 1
}
}
, "moon_phase": {
"percentIlluminated":"52",
"ageOfMoon":"22",
"phaseofMoon":"Waning Gibbous",
"hemisphere":"North",
"current_time": {
"hour":"21",
"minute":"24"
},
"sunrise": {
"hour":"8",
"minute":"42"
},
"sunset": {
"hour":"16",
"minute":"27"
},
"moonrise": {
"hour":"",
"minute":""
},
"moonset": {
"hour":"12",
"minute":"34"
}
},
"sun_phase": {
"sunrise": {
"hour":"8",
"minute":"42"
},
"sunset": {
"hour":"16",
"minute":"27"
}
}
}
So there is probably no error in the lua-script, but for some reason WU is not supplying all the information that is expected by the lua-script.
On the website of WU it says:
Code: Select all
Dec. 20, 2016 Opkomst Ondergang
Maan Geen maanopkomst 12:34 PM CET
So i guess we don't have a moon tonight
