Python Plugin: MoonPhases

Python and python framework

Moderator: leecollings

User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Python Plugin: MoonPhases

Post by ycahome »

Hi there.

I have read on this forum about an idea for "Moon Phases" script, jackslayter was the initial poster.....
I have managed to create such plugin.

Plugin updates a "Custom Sensor" Value with current state of Moon. This value can be used later on in order to update any scripts or to be used just a cosmetic improvement.

screen.JPG
screen.JPG (18.37 KiB) Viewed 5287 times

I hope you like it.

-->NOTE: This plugin requires Weather Underground key<--

Find latest version to https://github.com/ycahome/MoonPhases:


Installation instructions (you can USE PP-MANAGER plugin from http://www.domoticz.com/forum/viewtopic ... 193c8933a0 to install):
- Create Plugin Folder "MoonPhases" under "domoticz/plugins" folder
- Save this script as "plugin.py" on "MoonPhases" folder
- Extract "MoonPhases.zip" to "MoonPhases" folder
- Restart domoticz service.
- Add a new entry of this Hardware on your domoticz installation (Setup/Hardware/select and add "Moon Phases")


attachment.JPG
attachment.JPG (17.78 KiB) Viewed 5287 times



What am going to see?:
- Plugin will auto-add one Custom Sensor on your "Utility" Section named "<Your Hardware Name>- Lune".



MoonPhases.zip
(49.88 KiB) Downloaded 290 times
Last edited by ycahome on Sunday 11 March 2018 8:41, edited 9 times in total.
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: MoonPhases

Post by febalci »

@ycahome,

great work, exactly what was looking for some time, but too lazy to write a plugin about it :lol: One question; is there a specific reason why you used urllib instead of native HTTP/json connection of the Plugin Framework?
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MoonPhases

Post by corederoma82 »

It's possible that I have not plugin folder?
Attachments
Immagine.png
Immagine.png (36.68 KiB) Viewed 5264 times
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: MoonPhases

Post by febalci »

corederoma82 wrote: Friday 02 February 2018 12:52 It's possible that I have not plugin folder?
Install 32 bit Python3 first, then create a plugin folder.
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MoonPhases

Post by corederoma82 »

Thanks!
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MoonPhases

Post by corederoma82 »

Another question....where I have to put the weather key?

Thanks
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: MoonPhases

Post by ycahome »

corederoma82 wrote: Monday 05 February 2018 10:01 Another question....where I have to put the weather key?

Thanks
Here:
wukey.JPG
wukey.JPG (56.77 KiB) Viewed 5173 times
assenzuid
Posts: 135
Joined: Friday 13 November 2015 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: Python Plugin: MoonPhases

Post by assenzuid »

Great and thanks for sharing.

Would be very nice if Moonset and Moonrise, and Percent of the Moon Illuminated will be showed in a dummy sensor.
Is that possible?
User avatar
Marci
Posts: 531
Joined: Friday 22 January 2016 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: Python Plugin: MoonPhases

Post by Marci »

Ace - would be a useful astronomy tool if it could also give % cloud cover for a given Lat/Lon...
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!
assenzuid
Posts: 135
Joined: Friday 13 November 2015 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: Python Plugin: MoonPhases

Post by assenzuid »

When active my Domoticz Dashboard crashes.
Running Beta V3.8889
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: MoonPhases

Post by ycahome »

assenzuid wrote: Tuesday 06 February 2018 17:52 Great and thanks for sharing.

Would be very nice if Moonset and Moonrise, and Percent of the Moon Illuminated will be showed in a dummy sensor.
Is that possible?
Thank you.
Your comments noted for the next version ;-)
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: MoonPhases

Post by ycahome »

Marci wrote: Tuesday 06 February 2018 18:04 Ace - would be a useful astronomy tool if it could also give % cloud cover for a given Lat/Lon...
Cloud cover? Astronomy?

Maybe you mean % of moon covered.
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: MoonPhases

Post by ycahome »

assenzuid wrote: Tuesday 06 February 2018 18:10 When active my Domoticz Dashboard crashes.
Running Beta V3.8889
Can I suppose that you have python installed properly?

Would be nice if you can post some logs from your /var/log/syslog (if you have default log settings)
User avatar
Marci
Posts: 531
Joined: Friday 22 January 2016 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: Python Plugin: MoonPhases

Post by Marci »

ycahome wrote: Tuesday 06 February 2018 19:40
Marci wrote: Tuesday 06 February 2018 18:04 Ace - would be a useful astronomy tool if it could also give % cloud cover for a given Lat/Lon...
Cloud cover? Astronomy?

Maybe you mean % of moon covered.
Umm no... % cloud cover. As in, if I look up, are there clouds in the way of the sky... then astronomers / astrophotographers such as myself can get an alert when the sky is clear, and use the sensor to trigger observatory automation (slide off roof, fire up scope etc). DarkSkies makes it available in their JSON feed but the current DarkSkies sensors for Domoticz don’t utilise it. If WeatherUnderground make it available it’d be good to have bundled in with moon phase, as one generally can’t do much astrophotography when there’s a full moon due to the additional contribution it makes to light pollution. Ideally a combination of both moon phase and local cloud cover would be perfect for triggering automated setups. Seeing as my entire observatory / astrophotography rig is run from the same RaspberryPi that runs my Domoticz setup it just keeps everything nice and contained in a single unit.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python Plugin: MoonPhases

Post by htilburgs »

After installing MoonPhases Plugin, Domoticz Crashes:

Domoticz v3.8889
Domoticz Log Entry:

Code: Select all

2018-02-06 23:47:52.717  (Maanfases) Started.
2018-02-06 23:47:52.913  Error: Domoticz received fatal signal 11 !...
2018-02-06 23:47:52.915  Error:   /home/pi/domoticz/domoticz() [0x246814]
2018-02-06 23:47:52.915  Error:   /home/pi/domoticz/domoticz(_Z14signal_handleri+0x4c) [0x2468cc]
2018-02-06 23:47:52.915  Error:   /lib/arm-linux-gnueabihf/libc.so.6(__default_sa_restorer+0) [0x76c136b0]
/var/log/syslog:

Code: Select all

Feb  6 23:45:26 raspberrypi3 systemd[1]: Starting LSB: Home Automation System...
Feb  6 23:45:26 raspberrypi3 domoticz.sh[11910]: 2018-02-06 23:45:26.621  Domoticz V3.8889 (c)2012-2018 GizMoCuz
Feb  6 23:45:26 raspberrypi3 domoticz.sh[11910]: 2018-02-06 23:45:26.621  Build Hash: 7d40a8bc, Date: 2018-02-06 13:16:43
Feb  6 23:45:26 raspberrypi3 domoticz.sh[11910]: 2018-02-06 23:45:26.622  Startup Path: /home/pi/domoticz/
Feb  6 23:45:26 raspberrypi3 domoticz.sh[11910]: domoticz: Domoticz is starting up....
Feb  6 23:45:26 raspberrypi3 domoticz: Domoticz is starting up....
Feb  6 23:45:26 raspberrypi3 domoticz: Domoticz running...
Feb  6 23:45:26 raspberrypi3 systemd[1]: Started LSB: Home Automation System.
Feb  6 23:47:34 raspberrypi3 systemd[1]: Started Session c49 of user pi.
Feb  6 23:49:39 raspberrypi3 systemd[1]: Stopping LSB: Home Automation System...
Feb  6 23:49:40 raspberrypi3 systemd[1]: Stopped LSB: Home Automation System.
Further information about my system:

Code: Select all

pi@raspberrypi3:/ $ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 9.3 (stretch)
Release:	9.3
Codename:	stretch

Code: Select all

pi@raspberrypi3:/ $ uname -a
Linux raspberrypi3 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux

Code: Select all

pi@raspberrypi3:/ $ python --version
Python 2.7.13
pi@raspberrypi3:/ $ python3 --version
Python 3.5.3

Code: Select all

pi@raspberrypi3:/ $ dpkg --list | grep python
ii  dh-python                       2.20170125                   all          Debian helper tools for packaging Python libraries and applications
ii  libpython-stdlib:armhf          2.7.13-2                     armhf        interactive high-level object-oriented language (default python version)
ii  libpython2.7-minimal:armhf      2.7.13-2+deb9u2              armhf        Minimal subset of the Python language (version 2.7)
ii  libpython2.7-stdlib:armhf       2.7.13-2+deb9u2              armhf        Interactive high-level object-oriented language (standard library, version 2.7)
ii  libpython3-dev:armhf            3.5.3-1                      armhf        header files and a static library for Python (default)
ii  libpython3-stdlib:armhf         3.5.3-1                      armhf        interactive high-level object-oriented language (default python3 version)
ii  libpython3.4:armhf              3.4.4-3                      armhf        Shared Python runtime library (version 3.4)
ii  libpython3.4-minimal:armhf      3.4.4-3                      armhf        Minimal subset of the Python language (version 3.4)
ii  libpython3.4-stdlib:armhf       3.4.4-3                      armhf        Interactive high-level object-oriented language (standard library, version 3.4)
ii  libpython3.5:armhf              3.5.3-1                      armhf        Shared Python runtime library (version 3.5)
ii  libpython3.5-dev:armhf          3.5.3-1                      armhf        Header files and a static library for Python (v3.5)
ii  libpython3.5-minimal:armhf      3.5.3-1                      armhf        Minimal subset of the Python language (version 3.5)
ii  libpython3.5-stdlib:armhf       3.5.3-1                      armhf        Interactive high-level object-oriented language (standard library, version 3.5)
ii  python                          2.7.13-2                     armhf        interactive high-level object-oriented language (default version)
ii  python-apt-common               1.1.0~beta5                  all          Python interface to libapt-pkg (locales)
ii  python-minimal                  2.7.13-2                     armhf        minimal subset of the Python language (default version)
ii  python-rpi.gpio                 0.6.3~stretch-1              armhf        Python GPIO module for Raspberry Pi
ii  python2.7                       2.7.13-2+deb9u2              armhf        Interactive high-level object-oriented language (version 2.7)
ii  python2.7-minimal               2.7.13-2+deb9u2              armhf        Minimal subset of the Python language (version 2.7)
ii  python3                         3.5.3-1                      armhf        interactive high-level object-oriented language (default python3 version)
ii  python3-apt                     1.1.0~beta5                  armhf        Python 3 interface to libapt-pkg
ii  python3-dev                     3.5.3-1                      armhf        header files and a static library for Python (default)
ii  python3-minimal                 3.5.3-1                      armhf        minimal subset of the Python language (default python3 version)
ii  python3.5                       3.5.3-1                      armhf        Interactive high-level object-oriented language (version 3.5)
ii  python3.5-dev                   3.5.3-1                      armhf        Header files and a static library for Python (v3.5)
ii  python3.5-minimal               3.5.3-1                      armhf        Minimal subset of the Python language (version 3.5)
pi@raspberrypi3:/ $ 
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: MoonPhases

Post by ycahome »

htilburgs wrote: Tuesday 06 February 2018 23:59 After installing MoonPhases Plugin, Domoticz Crashes:

Domoticz v3.8889
Domoticz Log Entry:
Hi there again.

Your installation seems ok. I can't tell what exactly is causing this behavior.

You remind me some months ago that I personally faced the same behavior with another plugin.
Ended up to reinstall Domoticz and recreate database/sensors from scratch.

Don't get me wrong, am not saying that the plugin is correct and your installation is wrong. Just saying that didn't found any solution for "Domoticz received fatal signal 11 !..." error.

Do you have other plugins working?
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: MoonPhases

Post by ycahome »

Marci wrote: Tuesday 06 February 2018 23:24 Umm no... % cloud cover. As in, if I look up, are there clouds in the way of the sky...

Did you checked "Weather Underground" Hardware of Domoticz to see if this information is currently provided? I have a "Visibility" sensor on my setup maybe this can give you an indication (at least)!!

I would be glad to include any functionality on "Moon Phases" plugin but,i believe that "% Cloud cover"
is more "Weather" than "Moon status" related. Given that, if it is not provided via "Weather Underground" Hardware, maybe you can request to be added.
assenzuid
Posts: 135
Joined: Friday 13 November 2015 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: Python Plugin: MoonPhases

Post by assenzuid »

ycahome wrote: Tuesday 06 February 2018 19:43
assenzuid wrote: Tuesday 06 February 2018 18:10 When active my Domoticz Dashboard crashes.
Running Beta V3.8889
Can I suppose that you have python installed properly?

Would be nice if you can post some logs from your /var/log/syslog (if you have default log settings)

Code: Select all

With plugin enabled/installed 
var/log/syslog
Feb  6 18:06:48 MLTHomeDom systemd[1]: Starting LSB: Home Automation System...
Feb  6 18:06:48 MLTHomeDom domoticz.sh[24792]: 2018-02-06 18:06:48.225  Domoticz V3.8889 (c)2012-2018 GizMoCuz
Feb  6 18:06:48 MLTHomeDom domoticz.sh[24792]: 2018-02-06 18:06:48.225  Build Hash: 7d40a8bc, Date: 2018-02-06 13:16:43
Feb  6 18:06:48 MLTHomeDom domoticz.sh[24792]: 2018-02-06 18:06:48.226  Startup Path: /home/pi/domoticz/
Feb  6 18:06:48 MLTHomeDom domoticz.sh[24792]: domoticz: Domoticz is starting up....
Feb  6 18:06:48 MLTHomeDom domoticz: Domoticz is starting up....
Feb  6 18:06:48 MLTHomeDom domoticz: Domoticz running...
Feb  6 18:06:48 MLTHomeDom systemd[1]: Started LSB: Home Automation System.
Feb  6 18:07:32 MLTHomeDom systemd[1]: Created slice User Slice of root.
Feb  6 18:07:32 MLTHomeDom systemd[1]: Starting User Manager for UID 0...
Feb  6 18:07:32 MLTHomeDom systemd[1]: Started Session c5 of user root.
Feb  6 18:08:00 MLTHomeDom systemd[1]: Stopping LSB: Home Automation System...
Feb  6 18:08:00 MLTHomeDom systemd[1]: Stopped LSB: Home Automation System.
Python

Code: Select all

pi@MLTHomeDom:~ $ python --version
Python 2.7.13
pi@MLTHomeDom:~ $ python3 --version
Python 3.5.3

Code: Select all

pi@MLTHomeDom:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.3 (stretch)
Release:        9.3
Codename:       stretch

Code: Select all

pi@MLTHomeDom:~ $ uname -a
Linux MLTHomeDom 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux

Code: Select all

pi@MLTHomeDom:~ $ dpkg --list | grep python
ii  dh-python                         2.20170125                        all          Debian helper tools for packaging Python libraries and applications
ii  libpython-stdlib:armhf            2.7.13-2                          armhf        interactive high-level object-oriented language (default python version)
ii  libpython2.7-minimal:armhf        2.7.13-2+deb9u2                   armhf        Minimal subset of the Python language (version 2.7)
ii  libpython2.7-stdlib:armhf         2.7.13-2+deb9u2                   armhf        Interactive high-level object-oriented language (standard library, version 2.7)
ii  libpython3-dev:armhf              3.5.3-1                           armhf        header files and a static library for Python (default)
ii  libpython3-stdlib:armhf           3.5.3-1                           armhf        interactive high-level object-oriented language (default python3 version)
ii  libpython3.4:armhf                3.4.4-3                           armhf        Shared Python runtime library (version 3.4)
ii  libpython3.4-minimal:armhf        3.4.4-3                           armhf        Minimal subset of the Python language (version 3.4)
ii  libpython3.4-stdlib:armhf         3.4.4-3                           armhf        Interactive high-level object-oriented language (standard library, version 3.4)
ii  libpython3.5:armhf                3.5.3-1                           armhf        Shared Python runtime library (version 3.5)
ii  libpython3.5-dev:armhf            3.5.3-1                           armhf        Header files and a static library for Python (v3.5)
ii  libpython3.5-minimal:armhf        3.5.3-1                           armhf        Minimal subset of the Python language (version 3.5)
ii  libpython3.5-stdlib:armhf         3.5.3-1                           armhf        Interactive high-level object-oriented language (standard library, version 3.5)
ii  python                            2.7.13-2                          armhf        interactive high-level object-oriented language (default version)
ii  python-apt-common                 1.1.0~beta5                       all          Python interface to libapt-pkg (locales)
ii  python-cffi-backend               1.9.1-2                           armhf        Foreign Function Interface for Python calling C code - backend
ii  python-chardet                    2.3.0-2                           all          universal character encoding detector for Python2
ii  python-cryptography               1.7.1-3+b2                        armhf        Python library exposing cryptographic recipes and primitives (Python 2)
ii  python-enum34                     1.1.6-1                           all          backport of Python 3.4's enum package
ii  python-idna                       2.2-1                             all          Python IDNA2008 (RFC 5891) handling (Python 2)
ii  python-ipaddress                  1.0.17-1                          all          Backport of Python 3 ipaddress module (Python 2)
ii  python-minimal                    2.7.13-2                          armhf        minimal subset of the Python language (default version)
ii  python-openssl                    16.2.0-1                          all          Python 2 wrapper around the OpenSSL library
ii  python-pkg-resources              33.1.1-1                          all          Package Discovery and Resource Access using pkg_resources
ii  python-pyasn1                     0.1.9-2                           all          ASN.1 library for Python (Python 2 module)
ii  python-requests                   2.12.4-1                          all          elegant and simple HTTP library for Python2, built for human beings
ii  python-rpi.gpio                   0.6.3~stretch-1                   armhf        Python GPIO module for Raspberry Pi
ii  python-setuptools                 33.1.1-1                          all          Python Distutils Enhancements
ii  python-six                        1.10.0-3                          all          Python 2 and 3 compatibility library (Python 2 interface)
ii  python-urllib3                    1.19.1-1                          all          HTTP library with thread-safe connection pooling for Python
ii  python2.7                         2.7.13-2+deb9u2                   armhf        Interactive high-level object-oriented language (version 2.7)
ii  python2.7-minimal                 2.7.13-2+deb9u2                   armhf        Minimal subset of the Python language (version 2.7)
ii  python3                           3.5.3-1                           armhf        interactive high-level object-oriented language (default python3 version)
ii  python3-apt                       1.1.0~beta5                       armhf        Python 3 interface to libapt-pkg
ii  python3-dev                       3.5.3-1                           armhf        header files and a static library for Python (default)
ii  python3-minimal                   3.5.3-1                           armhf        minimal subset of the Python language (default python3 version)
ii  python3.5                         3.5.3-1                           armhf        Interactive high-level object-oriented language (version 3.5)
ii  python3.5-dev                     3.5.3-1                           armhf        Header files and a static library for Python (v3.5)
ii  python3.5-minimal                 3.5.3-1                           armhf        Minimal subset of the Python language (version 3.5)
assenzuid
Posts: 135
Joined: Friday 13 November 2015 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: Python Plugin: MoonPhases

Post by assenzuid »

These are my logs, @htilburgs post also some logs.
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: MoonPhases

Post by ycahome »

assenzuid wrote: Wednesday 07 February 2018 9:35 Running Beta V3.8889
htilburgs wrote: Tuesday 06 February 2018 23:59 Domoticz v3.8889
So, till now seems that you 2 running the same version 8889 and Domoticz crashes, correct?

Is there anyone else that runs 8889 and "Moon phases" working properly?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest