On a lot a standard weather stations the phase of the moon can be seen and it looks me a good idea that it would be nice to have this implemented also in Domoticz
Moon phase
Moderators: leecollings, remb0
-
Yihaaa
- Posts: 23
- Joined: Sunday 14 July 2013 10:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: The Netherlands
Moon phase
Hereby my suggestion to add a "moon phase" feature.
On a lot a standard weather stations the phase of the moon can be seen and it looks me a good idea that it would be nice to have this implemented also in Domoticz
On a lot a standard weather stations the phase of the moon can be seen and it looks me a good idea that it would be nice to have this implemented also in Domoticz
-
soiltech
- Posts: 1
- Joined: Wednesday 20 January 2016 20:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Moon phase
*bump*
would love to see this as well, it is an important part for gardeners using this controller.
would love to see this as well, it is an important part for gardeners using this controller.
- gizmocuz
- Posts: 2709
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Moon phase
Please give more details
URL, screenshot, API, usage, .....
URL, screenshot, API, usage, .....
Quality outlives Quantity!
- 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
I believe he'd like the data from: http://www.wunderground.com/weather/api ... onomy&MR=1gizmocuz wrote:Please give more details
URL, screenshot, API, usage, .....
more specifically:
moon_phase
percentIlluminated
ageOfMoon
phaseofMoon
hemisphere
If I'm not mistaken,
- gizmocuz
- Posts: 2709
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Moon phase
So something like a moon rise/set ?
I still do not get its usage ? Why is this important ? And can't the sun set/rise be used ?
I still do not get its usage ? Why is this important ? And can't the sun set/rise be used ?
Quality outlives Quantity!
- 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
Not sure, but found this: http://www.almanac.com/content/planting ... g-calendargizmocuz wrote:So something like a moon rise/set ?
I still do not get its usage ? Why is this important ? And can't the sun set/rise be used ?
Could be something in it
-
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
No need to add anything to Domoticz.
One has to use the existing capabilities to add things like moon rise/set in case needed.
Please see my lua script below. Do not forget to add 5 dummy sensors and name the script "script_time_moon.lua" before placing it in lua directory under scripts in domoticz folder.
PS I am still developing it
One has to use the existing capabilities to add things like moon rise/set in case needed.
Please see my lua script below. Do not forget to add 5 dummy sensors and name the script "script_time_moon.lua" before placing it in lua directory under scripts in domoticz folder.
PS I am still developing it
Code: Select all
-- Variables to customize ------------------------------------------------
local city = "London" -- Your city for Wunderground API
local countryCode = "UK" -- Your country code for Wunderground API
local idxmoonpercentage ='214' -- Your virtual moon percentage illuminated Device ID
local idxmoonage ='213' -- Your virtual moon age Device ID
local idxmoonphase ='210' -- Your virtual phase moon Device ID
local idxmoonrise='211' -- Your virtual moon rise variable ID
local idxmoonset='212' -- Your virtual moon set variable ID
local wuAPIkey = "" -- Your Weather Underground API Key
local DEBUG = 0 -- 0 , 1 for domoticz log
-------------------------------------------------------------------------
commandArray = {}
time = os.date("*t")
if ((time.min % 60)==0) then -- Run every hour. Check the wundergroud API limitation before changing this
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
-- API Wunderground
local file=assert(io.popen('curl http://api.wunderground.com/api/'..wuAPIkey..'/astronomy/q/'..countryCode..'/'..city..'.json'))
local raw = file:read('*all')
file:close()
s = (string.gsub(raw, "%c+", ""))
if( DEBUG == 1) then print('Moon'..s) end
-- moonrise
moonriseHour, moonriseMinute = string.match(s, [["moonrise": {"hour":"(%d+)","minute":"(%d+)"]])
print("Moonrise:\t"..moonriseHour..":"..moonriseMinute)
-- moonset
moonsetHour, moonsetMinute = string.match(s, [["moonset": {"hour":"(%d+)","minute":"(%d+)"]])
print("Moonset:\t"..moonsetHour..":"..moonsetMinute)
-- percentage of moon illuminated
percentIlluminated = string.match(s, [["percentIlluminated":"(%d+)"]])
print("Percent:\t"..percentIlluminated.."%")
-- age of moon since last new moon
age = string.match(s, [["ageOfMoon":"(%d+)"]])
print("Age:\t\t"..age)
-- Phase of the moon
moonPhase = string.match(s, [["phaseofMoon":"(.-)"]])
print("Phase:\t"..moonPhase)
commandArray[1] = {['UpdateDevice'] = idxmoonphase.."|0|"..moonPhase}
commandArray[2] = {['UpdateDevice'] = idxmoonrise.."|0|"..moonriseHour..moonriseMinute}
commandArray[3] = {['UpdateDevice'] = idxmoonset.."|0|"..moonsetHour..moonsetMinute}
commandArray[4] = {['UpdateDevice'] = idxmoonage.."|0|"..age}
commandArray[5] = {['UpdateDevice'] = idxmoonpercentage.."|0|"..percentIlluminated}
end
return commandArray
- papoo
- Posts: 126
- Joined: Friday 22 January 2016 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10
- Location: France
- Contact:
Re: Moon phase
forecast.io have this information in daily json
moonPhase: 0.34,
just add it in forecast.io hardware like wind or rain?
moonPhase (only defined on daily data points): A number representing the fractional part of the lunation number of the given day: a value of 0 corresponds to a new moon, 0.25 to a first quarter moon, 0.5 to a full moon, and 0.75 to a last quarter moon. (The ranges in between these represent waxing crescent, waxing gibbous, waning gibbous, and waning crescent moons, respectively.)
source : https://developer.forecast.io/docs/v2
Code: Select all
daily: {
data: [
{
time: 1465941600,
summary: "Light rain throughout the day.",
icon: "rain",
sunriseTime: 1465963534,
sunsetTime: 1466020087,
moonPhase: 0.34,
precipIntensity: 0.0141,
precipIntensityMax: 0.0317,
precipIntensityMaxTime: 1466017200,...just add it in forecast.io hardware like wind or rain?
moonPhase (only defined on daily data points): A number representing the fractional part of the lunation number of the given day: a value of 0 corresponds to a new moon, 0.25 to a first quarter moon, 0.5 to a full moon, and 0.75 to a last quarter moon. (The ranges in between these represent waxing crescent, waxing gibbous, waning gibbous, and waning crescent moons, respectively.)
source : https://developer.forecast.io/docs/v2
- gizmocuz
- Posts: 2709
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Moon phase
Quality outlives Quantity!
-
jackslayter
- Posts: 59
- Joined: Tuesday 07 October 2014 11:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: France RA
- Contact:
Re: Moon phase
and add dummy device in Dz with moon phase like Alert device 
RPi2 + RFLink, Domoticz
Chacon - micromodule 200w, remote 3b, 2x module 1000w, remote 16b, smoke detector, door contact, 2x 3500w plug
Oregon - 3x Thgr122Nx / OWL - CM180 / TRC02_2 RGB / Cheap - PiR, door contact, Temp Hum / 4x REVOLT NC5461
Chacon - micromodule 200w, remote 3b, 2x module 1000w, remote 16b, smoke detector, door contact, 2x 3500w plug
Oregon - 3x Thgr122Nx / OWL - CM180 / TRC02_2 RGB / Cheap - PiR, door contact, Temp Hum / 4x REVOLT NC5461
-
jackslayter
- Posts: 59
- Joined: Tuesday 07 October 2014 11:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: stable
- Location: France RA
- Contact:
Re: Moon phase
yes, like Alert sensor
RPi2 + RFLink, Domoticz
Chacon - micromodule 200w, remote 3b, 2x module 1000w, remote 16b, smoke detector, door contact, 2x 3500w plug
Oregon - 3x Thgr122Nx / OWL - CM180 / TRC02_2 RGB / Cheap - PiR, door contact, Temp Hum / 4x REVOLT NC5461
Chacon - micromodule 200w, remote 3b, 2x module 1000w, remote 16b, smoke detector, door contact, 2x 3500w plug
Oregon - 3x Thgr122Nx / OWL - CM180 / TRC02_2 RGB / Cheap - PiR, door contact, Temp Hum / 4x REVOLT NC5461
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Moon phase
For Python-applications the modules Astral and PyEphem provide easy & accurate calculation of moonphase, etc.
Last edited by Toulon7559 on Wednesday 01 February 2017 13:42, edited 4 times in total.
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.
- gizmocuz
- Posts: 2709
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Moon phase
I shown the calculation part already above... not that difficult, and should be easy to add to the system, just like the sunset/sunrise is calculated
Infact, someone could use that as a start place to implement it
Infact, someone could use that as a start place to implement it
Quality outlives Quantity!
- wizjos
- Posts: 79
- Joined: Monday 07 March 2016 19:35
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Moon phase
Thanks @alexsh1!
I used your script and modified it somewhat
The result looks like this: As you can see with a Custom sensor that represents the actual moonphase as an icon
I used your script and modified it somewhat
The result looks like this: As you can see with a Custom sensor that represents the actual moonphase as an icon
Code: Select all
-- MoonPhase script
-- Original by: alexsh1 in https://www.domoticz.com/forum/viewtopic.php?f=31&t=107
-- Adapted by wizjos 26-10-2016
-- Requirements:
-- 1 uservariable "MoonphaseCheck"
-- 1 dummy sensor (type percentage) for moonpercentage
-- 3 dummy sensors (type text) for moonphase, moonrise and moonset
-- 2 dummy sensors (type custom) for moonage and moonphase icon
-- 8 custom icon sets (http://domoticz-icon.aurelien-loyer.fr/) for the moonphase icons
-- note: Only the first (or 'on') icon of a custom iconset is used, so you need 8 different sets of custom icons
-- The icons are referenced by their internal number.
-- Variables to customize ------------------------------------------------
local checkvar = "MoonphaseCheck" -- name of the uservar to check if update is allowed
local checktime = 3600 -- check allowed every x seconds 3600 = 60 min. Check the wundergroud API limitation before changing this
local city = "<YOUR CITY HERE>" -- Your city for Wunderground API
local countryCode = "NL" -- Your country code for Wunderground API
local idxmoonpercentage ='125' -- Your virtual moon percentage illuminated Device ID
local idxmoonage ='131' -- Your virtual moon age Device ID
local idxmoonphase ='132' -- Your virtual moon phase Device ID
local idxmoonrise='124' -- Your virtual moon rise variable ID
local idxmoonset='127' -- Your virtual moon set variable ID
local idxmoonphaseicon = "133" -- Your virtual moon phase icon variable ID
local wuAPIkey = "<YOUR API KEY HERE>" -- Your Weather Underground API Key
local DOMO_IP = "<YOUR DOMOTICZ IP HERE>" -- Domoticz ip address
local DOMO_PORT = "8084" -- Domoticz port
local tempfilename = '/var/tmp/phase.tmp' -- can be anywhere writeable
local debug=false -- false, true for domoticz log
-------------------------------------------------------------------------
function file_exists(path)
-- function to check if a file exists
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
function timedifference(s)
-- function to determine the difference in seconds between the current time and a given one
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
function may_update(device, timeelapsed)
-- function to check whether an update is allowed
return uservariables_lastupdate[device] == nil or timedifference(uservariables_lastupdate[device]) >= timeelapsed
end
commandArray = {}
time = os.date("*t")
url='http://api.wunderground.com/api/'..wuAPIkey..'/astronomy/q/'..countryCode..'/'..city..'.json'
if (may_update(checkvar,checktime)==true) or (file_exists(tempfilename)==false) then
-- read API Wunderground
if debug then
message ="Moonphase - Collecting data from: "..url
if (file_exists(tempfilename)==false) then
message=message.."because /var/tmp/phase.tmp does not exist."
end
if (may_update(checkvar,checktime)==true) then
message=message.." it's time."
end
print(message)
print("Difference: "..timedifference(uservariables_lastupdate[checkvar]).." seconds")
end
read = os.execute('curl -s -o '..tempfilename..' "'..url..'"')
commandArray['Variable:'..checkvar]=time.hour..":"..time.min
file = io.open(tempfilename, "r")
s= file:read("*a")
s = (string.gsub(s, "%c+", ""))
file:close()
-- moonrise
moonriseHour, moonriseMinute = string.match(s, [["moonrise": {"hour":"(%d+)","minute":"(%d+)"]])
print("Moonrise:\t"..moonriseHour..":"..moonriseMinute)
-- moonset
moonsetHour, moonsetMinute = string.match(s, [["moonset": {"hour":"(%d+)","minute":"(%d+)"]])
print("Moonset:\t"..moonsetHour..":"..moonsetMinute)
-- percentage of moon illuminated
percentIlluminated = string.match(s, [["percentIlluminated":"(%d+)"]])
print("Percent:\t"..percentIlluminated.."%")
-- age of moon since last new moon
age = string.match(s, [["ageOfMoon":"(%d+)"]])
print("Age:\t\t"..age)
-- Phase of the moon
-- set the moonPhaseIcon to your appropriate icon number (8 x)
moonPhase = string.match(s, [["phaseofMoon":"(.-)"]])
if moonPhase=="New" then
moonPhaseIdx = 1
moonPhaseIcon = 103
moonPhase = "Nieuwe maan"
end
if moonPhase=="Waxing Crescent" then
moonPhaseIdx = 2
moonPhaseIcon = 104
moonPhase = "Wassende halve maan"
end
if moonPhase=="First Quarter" then
moonPhaseIdx = 3
moonPhaseIcon = 105
moonPhase = "Eerste kwartier"
end
if moonPhase=="Waxing Gibbous" then
moonPhaseIdx = 4
moonPhaseIcon = 106
moonPhase = "Wassende maan"
end
if moonPhase=="Full" then
moonPhaseIdx = 5
moonPhaseIcon = 107
moonPhase = "Volle maan"
end
if moonPhase=="Waning Gibbous" then
moonPhaseIdx = 6
moonPhaseIcon = 108
moonPhase = "Afnemende maan"
end
if moonPhase=="Last Quarter" then
moonPhaseIdx = 7
moonPhaseIcon = 109
moonPhase = "Laatste kwartier"
end
if moonPhase=="Waning Crescent" then
moonPhaseIdx = 8
moonPhaseIcon = 110
moonPhase = "Afnemende halve maan"
end
-- Because there is no api command available to set a custom icon a JSON call is made
-- This requires the following parameters:
-- type = setused (not to be changed)
-- idx = idxmoonphaseicon (not to be changed here)
-- name = Maanfase (This is the Name of the control. You need to pass this value. This name will be displayd in the Domoticz GUI.
-- description = (left empty: no need for a description in the Domoticz GUI)
-- switchtype = 0 (not to be changed)
-- customimage = moonPhaseIcon (not to be changed here)
-- devoptions = 1;%20 (This is the 'axis-label'. Because only a number is sent a space (%20) is given as axis-label, resulting in no axis-label in Domoticz GUI (not to be changed)
-- used = true (not to be changed)
os.execute('curl -s -i -H "Accept: application/json" "http://"'..DOMO_IP..'":"'..DOMO_PORT..'"/json.htm?type=setused&idx="'..idxmoonphaseicon..'"&name=Maanfase&description=&switchtype=0&customimage="'..moonPhaseIcon..'"&devoptions=1;%20&used=true"')
print("Phase:\t"..moonPhase)
commandArray[1] = {['UpdateDevice'] = idxmoonphase.."|0|"..moonPhase}
commandArray[2] = {['UpdateDevice'] = idxmoonrise.."|0|"..moonriseHour..":"..moonriseMinute}
commandArray[3] = {['UpdateDevice'] = idxmoonset.."|0|"..moonsetHour..":"..moonsetMinute}
commandArray[4] = {['UpdateDevice'] = idxmoonage.."|0|"..age}
commandArray[5] = {['UpdateDevice'] = idxmoonpercentage.."|0|"..percentIlluminated}
commandArray[6] = {['UpdateDevice'] = idxmoonphaseicon.."|0|"..moonPhaseIdx}
else
if debug then print("MoonPhase - Update not allowed: Difference is "..timedifference(uservariables_lastupdate[checkvar]).." seconds") end
end
return commandArray
-
Derik
- Posts: 1605
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: Moon phase
mmm try this get working...
Do i need the city name
Or the station id?
And the variable: Do not understand this function?
Please explane som more...
Nice icon..
please share:
https://drive.google.com/drive/u/0/fold ... WdHV1Qxbm8
[email protected]
Do i need the city name
Or the station id?
And the variable: Do not understand this function?
Please explane som more...
Nice icon..
please share:
https://drive.google.com/drive/u/0/fold ... WdHV1Qxbm8
[email protected]
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
Good work @ wizjos!
Is your moon icon changing according to the moon phase? Very nice - now I'd like to implement it too
Is your moon icon changing according to the moon phase? Very nice - now I'd like to implement it too
-
Amsterdam020
- Posts: 55
- Joined: Saturday 05 March 2016 21:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5629
- Contact:
Re: Moon phase
https://en.m.wikipedia.org/wiki/Agricultural_astrology
"There is a lack of scientific evidence proving the beneficial effects of astrological gardening."
Nonetheless the moon phase is a nice extension to domoticz.
"There is a lack of scientific evidence proving the beneficial effects of astrological gardening."
Nonetheless the moon phase is a nice extension to domoticz.
Rp3, youlesss, rfxcom, philips hue, dsb1820
- wizjos
- Posts: 79
- Joined: Monday 07 March 2016 19:35
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Moon phase
The city nameDerik wrote:mmm try this get working...
Do i need the city name
Or the station id?
The url should look like this:
Code: Select all
http://api.wunderground.com/api/<YourwuAPIkey>/astronomy/q/NL/Nijmegen.jsonI'd love to, but I'm not completely sure about what exactly your question/problem is. When looking at your screenshot you're adding a uservariable. I use this variable to determine when the last check (= property lastupdated of this uservariable) was done. At this time plus 3600 seconds ore more the check/update is performed again. The uservariable displays a time, but this is purely cosmetic. The check is performed against the time of the last update.Derik wrote: And the variable:
Do not understand this function?
Please explane som more...
Does that answer your question/clarifies things somewhat?
I was not aware of this site. Thanks for mentioning! I'll post my icon-sets a soon as I've sanitized things...Derik wrote:Nice icon..
please share:
https://drive.google.com/drive/u/0/fold ... WdHV1Qxbm8
[email protected]
Last edited by wizjos on Wednesday 26 October 2016 22:10, edited 1 time in total.
- wizjos
- Posts: 79
- Joined: Monday 07 March 2016 19:35
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Moon phase
I can confirm it isalexsh1 wrote:Good work @ wizjos!
Is your moon icon changing according to the moon phase? Very nice - now I'd like to implement it too
Who is online
Users browsing this forum: No registered users and 1 guest