Page 3 of 4
Re: Moon phase
Posted: Wednesday 04 January 2017 19:43
by Derik
A solution for the api kill:
viewtopic.php?f=38&t=8979
Please ...
The icons include a how to....
xxx
Re: Moon phase
Posted: Saturday 21 January 2017 9:43
by Minglarn
wizjos wrote:Thanks @alexsh1!
I used your script and modified it somewhat
The result looks like this: MoonPhase.PNG
As you can see with a Custom sensor that represents the actual moonphase as an icon
Code: Select all
-- MoonPhase script
......
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)
...
Hi! I'm planing to write a php script for moonphase. I've got it running and even show the right moon phase picture.
I was lurking around in the forum and saw you script and got curious when I noticed the this line in your code !
Is this a new function for domoticz?
So it is possible to change icon/picture with a JSON url ?
As I dont really understand you code, could you please explain the right URL to change the icon for me?
Re: Moon phase
Posted: Monday 24 April 2017 13:16
by bertbigb
Can anyone help me where to find the icons? Because that is the nicest visible part in this script in my opinion.
Re: Moon phase
Posted: Sunday 14 May 2017 8:58
by bertbigb
bertbigb wrote:
Can anyone help me where to find the icons? Because that is the nicest visible part in this script in my opinion.
Really no one can point me to a location where to find the pictures?
Re: Moon phase
Posted: Sunday 14 May 2017 9:11
by Derik
@ bert i do also not have the icons...
Re: Moon phase
Posted: Wednesday 17 May 2017 12:17
by assenzuid
Someone able to share the icon set and how to implement?
Re: Moon phase
Posted: Friday 02 June 2017 23:18
by Hesmink
Tiny issue: If you happen to live in a city with a space in the name, you have to escape the space to make it work, like:
local city = "Den%20Haag"
Re: Moon phase
Posted: Sunday 11 June 2017 13:15
by Eddiever
Scratching my head. Dunno what I missed. I used the wiki page to implement the moonphase. But I get this error:
- moon.PNG (11.14 KiB) Viewed 5153 times
Figured it out. Stupid mistake, Made an error in adjusting City (hard to know your own city were one lives for over 40 years
)
Re: Moon phase
Posted: Thursday 15 June 2017 16:11
by bertbigb
From the last error message I also could find out where to find the icons:
The icons for the moonphase can be found at
https://github.com/robgeerts/dashticz_v2
They are part of the dashticz web interface
Re: Moon phase
Posted: Thursday 15 June 2017 22:40
by assenzuid
How to configure domoticz to show the correct icon(s)
Re: Moon phase
Posted: Tuesday 20 June 2017 19:42
by Jan Jansen
wizjos wrote:Thanks @alexsh1!
I used your script and modified it somewhat.
As you can see with a Custom sensor that represents the actual moonphase as an icon
You have also contributed to creating a similar script used with Dashticz. Together with Dashticz, it works fine. But Dashticz does not always fit on my older devices. So it would be nice if the icon (custom text sensor Domoticz GUI) could be adjusted.
I already have a user variable "MoonPicture" (current value: moon.59.png). The relevant icons can be found at
https://github.com/robgeerts/dashticz_v2 I assume that these icons can be uploaded using the "custom icon uploader" (am I right??). Is it possible to customize the code to make use of the user variable "MoonPicture"?
Thanks in advance!
Jan
Re: Moon phase
Posted: Tuesday 20 June 2017 20:06
by natywna
Nice work! In full moon I was always a little bit weird and slep not too good.
Re: Moon phase
Posted: Tuesday 20 June 2017 20:53
by Eddiever
assenzuid wrote:How to configure domoticz to show the correct icon(s)
https://www.domoticz.com/wiki/Dashticz_ ... plications
See the link above, but this is for Dashticz. I had a some troubles getting it to work but it does now and I love it!
Re: Moon phase
Posted: Tuesday 04 July 2017 10:17
by jackslayter
hi,
I try to make a plugin for moon phase but I have problem with python
error in dz log : "Error: (Lune) Failed to update device"
Code: Select all
"""
<plugin key="Lune" name="Lune" author=" " version="1.0.0" wikilink="http://www.domoticz.com/wiki/plugins/" externallink=" ">
<params>
<param field="Mode1" label="Key WU" width="200px" required="true" default="5ea448da70b1136f"/>
<param field="Mode2" label="Code Country" width="100px" required="true" default="fr"/>
<param field="Mode3" label="City" width="300px" required="true" default="paris"/>
<param field="Mode4" label="Polling interval (minutes, 30 mini)" width="40px" required="true" default="2"/>
<param field="Mode6" label="Debug" width="75px">
<options>
<option label="True" value="Debug"/>
<option label="False" value="Normal" default="True" />
</options>
</param>
</params>
</plugin>
"""
import Domoticz
# import urllib
# from urllib.request import request, urlopen
import urllib.request
import json
from datetime import datetime
from datetime import timedelta
icons = {"nouvelle": "nouvelle.zip",
"precroi": "precroi.zip",
"prequar": "prequar.zip",
"gibcroi": "gibcroi.zip",
"pleine": "pleine.zip",
"gibdecroi": "gibdecroi.zip",
"derquar": "derquar.zip",
"dercroi": "dercroi.zip"}
# New/Waxing Crescent/First Quarter/Waxing Gibbous/Full/Waning Gibbous/Last Quarter/Waning Crescent
# nouvelle/precroi/prequar/gibcroi/pleine/gibdecroi/derquar/dercroi
class BasePlugin:
def __init__(self):
self.debug = False
self.nextupdate = datetime.now()
self.pollinterval = 60 # default polling interval in minutes
self.error = False
return
def onStart(self):
global icons
Domoticz.Debug("onStart called")
if Parameters["Mode6"] == 'Debug':
self.debug = True
Domoticz.Debugging(1)
DumpConfigToLog()
else:
Domoticz.Debugging(0)
# load custom battery images
for key, value in icons.items():
if key not in Images:
Domoticz.Image(value).Create()
Domoticz.Debug("Added icon: " + key + " from file " + value)
Domoticz.Debug("Number of icons loaded = " + str(len(Images)))
for image in Images:
Domoticz.Debug("Icon " + str(Images[image].ID) + " " + Images[image].Name)
# create the mandatory child device if it does not yet exist
if 1 not in Devices:
Domoticz.Device(Name="Lune", Unit=1, TypeName="Custom",
Options={"Custom": "1;"},
Used=1).Create()
# check polling interval parameter
try:
temp = int(Parameters["Mode4"])
except:
Domoticz.Error("Invalid polling interval parameter")
else:
if temp < 1:
temp = 1 # minimum polling interval
Domoticz.Error("Specified polling interval too short: changed to 30 minutes")
elif temp > 1440:
temp = 1440 # maximum polling interval is 1 day
Domoticz.Error("Specified polling interval too long: changed to 1440 minutes (24 hours)")
self.pollinterval = temp
Domoticz.Log("Using polling interval of {} minutes".format(str(self.pollinterval)))
def onStop(self):
Domoticz.Debug("onStop called")
Domoticz.Debugging(0)
def onHeartbeat(self):
now = datetime.now()
if now >= self.nextupdate:
self.nextupdate = now + timedelta(minutes=self.pollinterval)
# data=json.loads(urllib.request.urlopen("http://api.wunderground.com/api/5ea448da70b1136f/astronomy/q/fr/paris.json").read().decode('ascii'))
data = json.loads(urllib.request.urlopen(
"http://api.wunderground.com/api/" + Parameters["Mode1"] + "/astronomy/q/" + Parameters["Mode2"] + "/" +
Parameters["Mode3"] + ".json").read().decode('ascii'))
lune = data['moon_phase']['phaseofMoon']
# Domoticz.Log(str(lune))
self.UpdateDevice(lune)
# New/Waxing Crescent/First Quarter/Waxing Gibbous/Full/Waning Gibbous/Last Quarter/Waning Crescent
# nouvelle/precroi/prequar/gibcroi/pleine/gibdecroi/derquar/dercroi
def UpdateDevice(self, lune):
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
if 1 in Devices:
if lune == "New":
icon = "nouvelle"
datafr = "nouvelle lune"
elif lune == "Waxing Crescent":
icon = "precroi"
datafr = "premier croissant"
elif lune == "First Quarter":
icon = "prequar"
datafr = "premier quartier"
elif lune == "Waxing Gibbous":
icon = "gibcroi"
datafr = "gibeuse croissante"
elif lune == "Full":
icon = "pleine"
datafr = "pleine lune"
elif lune == "Waning Gibbous":
icon = "gibdecroi"
datafr = "gibeuse decroissante"
elif lune == "Last Quarter":
icon = "derquar"
datafr = "dernier quartier"
elif lune == "Waning Crescent":
icon = "dercroi"
datafr = "dernier croissant"
try:
Devices[1].Update(nValue=0, sValue=str(datafr), Image=Images[icon].ID)
except:
Domoticz.Error("Failed to update device")
return
global _plugin
_plugin = BasePlugin()
def onStart():
global _plugin
_plugin.onStart()
def onStop():
global _plugin
_plugin.onStop()
def onHeartbeat():
global _plugin
_plugin.onHeartbeat()
# Generic helper functions
def DumpConfigToLog():
for x in Parameters:
if Parameters[x] != "":
Domoticz.Debug("'" + x + "':'" + str(Parameters[x]) + "'")
Domoticz.Debug("Device count: " + str(len(Devices)))
for x in Devices:
Domoticz.Debug("Device: " + str(x) + " - " + str(Devices[x]))
Domoticz.Debug("Device ID: '" + str(Devices[x].ID) + "'")
Domoticz.Debug("Device Name: '" + Devices[x].Name + "'")
Domoticz.Debug("Device nValue: " + str(Devices[x].nValue))
Domoticz.Debug("Device sValue: '" + Devices[x].sValue + "'")
return
and icons for test
https://drive.google.com/file/d/0B3QY9M ... sp=sharing
thank you
Re: Moon phase
Posted: Tuesday 15 August 2017 14:17
by tottka
Fantastic thread & thank you for the work you did on this.
I'm wondering how you determined the internal icon numbers?
I think I understand most of what you did & I'm ready to give it a go.
thanks
Re: Moon phase
Posted: Wednesday 13 September 2017 17:34
by htilburgs
In some rare occassions (like today
) the "moonrise" hour and minute are empty
"moonrise": {
"hour":"",
"minute":""
}
Searching the Wunderground forum tells me "This happens when a day does not have a moon rise. In this case, the moon rose yesterday"
https://apicommunity.wunderground.com/w ... g-sometime
I'm looking for a way to modify the lua script, so the script keeps running and not the error
64: attempt to concatenate global 'moonriseMinute' (a nil value)
see also:
http://www.domoticz.com/forum/viewtopic ... 67&t=19404
Re: Moon phase
Posted: Wednesday 13 September 2017 19:44
by elmortero
something like if moonriseMinute == nil then moonriseMinute = '--' end (and same for the rest of the fetched values)
That should avoid giving an error and in your textsensor would get --:--
Re: Moon phase
Posted: Wednesday 13 September 2017 20:45
by htilburgs
elmortero wrote: ↑Wednesday 13 September 2017 19:44
something like if moonriseMinute == nil then moonriseMinute = '--' end (and same for the rest of the fetched values)
That should avoid giving an error and in your textsensor would get --:--
Yes, that did the trick. Changed part:
Code: Select all
-- moonrise
moonriseHour, moonriseMinute = string.match(s, [["moonrise": {"hour":"(%d+)","minute":"(%d+)"]])
if moonriseHour == nil then moonriseHour = '--' end
if moonriseMinute == nil then moonriseMinute = '--' end
if debug then print("Moonrise:\t"..moonriseHour..":"..moonriseMinute) end
-- moonset
moonsetHour, moonsetMinute = string.match(s, [["moonset": {"hour":"(%d+)","minute":"(%d+)"]])
if moonsetHour == nil then moonsetHour = "--" end
if moonsetMinute == nil then moonsetMinute = "--" end
if debug then print("Moonset:\t"..moonsetHour..":"..moonsetMinute) end
Re: Moon phase
Posted: Wednesday 13 September 2017 20:49
by EdwinK
Thanks. Seems to work again
(Why don't we have a 'thanks' button in here?)
Re: Moon phase
Posted: Wednesday 13 September 2017 21:04
by htilburgs
EdwinK wrote: ↑Wednesday 13 September 2017 20:49
Thanks. Seems to work again
(Why don't we have a 'thanks' button in here?)
I've one default on my keyboard
- thanks.jpg (8.44 KiB) Viewed 4428 times