Moon phase

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Moon phase

Post by Derik »

@ wizjos,

Thanks for the support

I do not understand the uservariable..
Is this correct?
ScreenShot080.jpg
ScreenShot080.jpg (60.95 KiB) Viewed 3510 times
Or what type do i need?


And this is ok?
ScreenShot081.jpg
ScreenShot081.jpg (91.85 KiB) Viewed 3510 times
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
wizjos
Posts: 78
Joined: Monday 07 March 2016 19:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Moon phase

Post 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!
alexsh1
Posts: 169
Joined: Wednesday 30 September 2015 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8975
Location: United Kingdom
Contact:

Re: Moon phase

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

Re: Moon phase

Post by Derik »

mmm Not working...
ScreenShot082.jpg
ScreenShot082.jpg (62.74 KiB) Viewed 3480 times
What can be the dombo error /mistake that i make?
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: Moon phase

Post by Derik »

got him:
ScreenShot083.jpg
ScreenShot083.jpg (62.39 KiB) Viewed 3466 times
shame... did not not have activated the srcipt funtion:
ScreenShot084.jpg
ScreenShot084.jpg (16.25 KiB) Viewed 3466 times
Only i think i changed the rise and set, is that correct??
ScreenShot085.jpg
ScreenShot085.jpg (13.64 KiB) Viewed 3466 times
And will you please tell me how you make the changing button with a moon icon...
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
LouiS22
Posts: 433
Joined: Friday 27 February 2015 13:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: Moon phase

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

Re: Moon phase

Post by Derik »

runs every minute ..
Because it is a lua time script...
should be great when this can be adjustable
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: Moon phase

Post 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
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: Moon phase

Post by Derik »

get a warning from wu..
ScreenShot086.jpg
ScreenShot086.jpg (30.26 KiB) Viewed 3438 times
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: Moon phase

Post 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)
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
LouiS22
Posts: 433
Joined: Friday 27 February 2015 13:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: Moon phase

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

Re: Moon phase

Post by Derik »

Perhaps someonebcab make this script working as a lua with a crontab.... In steat op lua time
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
alexsh1
Posts: 169
Joined: Wednesday 30 September 2015 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8975
Location: United Kingdom
Contact:

Re: Moon phase

Post 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.
alexsh1
Posts: 169
Joined: Wednesday 30 September 2015 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8975
Location: United Kingdom
Contact:

Re: Moon phase

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

Re: Moon phase

Post by Derik »

dear i did set time to 4800 only i still get a warning..:
ScreenShot092.jpg
ScreenShot092.jpg (56.32 KiB) Viewed 3382 times
ScreenShot091.jpg
ScreenShot091.jpg (34.94 KiB) Viewed 3382 times
Or can i set the time of the lua script set to a other time to?
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: Moon phase

Post by Derik »

Strange thing happend
I did not make a change..:
ScreenShot094.jpg
ScreenShot094.jpg (105.27 KiB) Viewed 3369 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)
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: Moon phase

Post by Derik »

did make no change to anything
Only a update..
ScreenShot102.jpg
ScreenShot102.jpg (73.51 KiB) Viewed 3354 times
working again...:-)

Only in the log errors..
ScreenShot101.jpg
ScreenShot101.jpg (138.58 KiB) Viewed 3354 times
...
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
alexsh1
Posts: 169
Joined: Wednesday 30 September 2015 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8975
Location: United Kingdom
Contact:

Re: Moon phase

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

Re: Moon phase

Post 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??
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
cyberclwn
Posts: 103
Joined: Thursday 20 August 2015 22:53
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Moon phase

Post 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 :)
3xPi 2B (Domoticz "live", Domoticz "sandbox", PhotoFrame)
RFXCom433(E), KaKu, Oregon Scientific, Keyes 2-relay, Logitech Media Server, MiLight, Smartwares heating controller(2x), IR Send/Receive, Keyes PIR, XH-M131 DuskSensor, DHT22/11
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest