Page 3 of 3

Re: Python Plugin: MoonPhases

Posted: Thursday 22 March 2018 21:29
by brainpaincgn
I hope this is the right output...

Code: Select all

2018-03-22 21:27:23.318 (Philips Hue) Lighting Limitless/Applamp (Scene Sonnenuntergang Savanne)
2018-03-22 21:27:23.320 (Philips Hue) Lighting Limitless/Applamp (Scene Hell)
2018-03-22 21:27:23.322 (Philips Hue) Lighting Limitless/Applamp (Scene Aus)
2018-03-22 21:27:23.325 (Philips Hue) Lighting Limitless/Applamp (Scene Lesen)
2018-03-22 21:27:23.327 (Philips Hue) Lighting Limitless/Applamp (Scene Konzentrieren)
2018-03-22 21:27:23.329 (Philips Hue) Lighting Limitless/Applamp (Scene Frühlingsblüten)
2018-03-22 21:27:23.336 (Philips Hue) Lighting Limitless/Applamp (Küche Feelings)
2018-03-22 21:27:23.342 (Philips Hue) Lighting Limitless/Applamp (Küche Bunt)
2018-03-22 21:27:23.345 (Philips Hue) Lighting Limitless/Applamp (Scene Letzter "Ein" Zustand)
2018-03-22 21:27:23.347 (Philips Hue) Lighting Limitless/Applamp (Scene Sonnenuntergang Savanne)
2018-03-22 21:27:23.349 (Philips Hue) Lighting Limitless/Applamp (Scene Aus)
2018-03-22 21:27:23.353 (Philips Hue) Lighting Limitless/Applamp (Scene Konzentration)
2018-03-22 21:27:23.354 MQTT: connected to: localhost:1883
2018-03-22 21:27:23.356 (Philips Hue) Lighting Limitless/Applamp (Scene Frühlingsblüten)
2018-03-22 21:27:23.359 (Philips Hue) Lighting Limitless/Applamp (Scene Nordlichter)
2018-03-22 21:27:23.362 (Philips Hue) Lighting Limitless/Applamp (Scene Letzter "Ein" Zustand)
2018-03-22 21:27:23.365 (Philips Hue) Lighting Limitless/Applamp (Scene Tropendämmerung)
2018-03-22 21:27:23.373 (Philips Hue) Lighting Limitless/Applamp (Küche Hell)
2018-03-22 21:27:23.380 (Philips Hue) Lighting Limitless/Applamp (Küche Kranhäuser)
2018-03-22 21:27:23.383 (Philips Hue) Lighting Limitless/Applamp (Scene Energie tanken)
2018-03-22 21:27:23.386 (Philips Hue) Lighting Limitless/Applamp (Scene Entspannen)
2018-03-22 21:27:23.393 (Philips Hue) Lighting Limitless/Applamp (Küche Aus)
2018-03-22 21:27:23.396 (Philips Hue) Lighting Limitless/Applamp (Scene Nachtlicht)
2018-03-22 21:27:23.403 (Philips Hue) Lighting Limitless/Applamp (Küche Letzter "Ein" Zustand)
2018-03-22 21:27:23.412 (Philips Hue) Lighting Limitless/Applamp (Küche Nachtlicht)
2018-03-22 21:27:23.416 (Philips Hue) Lighting Limitless/Applamp (Scene Nordlichter)
2018-03-22 21:27:23.424 (Philips Hue) Lighting Limitless/Applamp (Küche Gedimmt)
2018-03-22 21:27:23.428 (Philips Hue) Lighting Limitless/Applamp (Scene Gedimmt)
2018-03-22 21:27:23.432 (Philips Hue) Lighting Limitless/Applamp (Scene Tropendämmerung)
2018-03-22 21:27:23.435 (Philips Hue) Lighting Limitless/Applamp (Scene Aktivieren)
2018-03-22 21:27:23.437 (Moon Phases) Entering work loop.
2018-03-22 21:27:23.437 (Moon Phases) Initialized version 1.0.3, author 'ycahome ft. jackslayter'
2018-03-22 21:27:23.440 (Philips Hue) Lighting Limitless/Applamp (Scene Entspannen)
2018-03-22 21:27:23.441 (BatteryLevels) Debug logging mask set to: NONE
2018-03-22 21:27:23.441 (BatteryLevels) Using polling interval of 60 minutes
2018-03-22 21:27:23.455 MQTT: Subscribed
2018-03-22 21:27:23.512 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:23.519 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:23.523 Python EventSystem: Initalizing event module.
2018-03-22 21:27:23.523 EventSystem: Started
2018-03-22 21:27:23.523 EventSystem: Queue thread started...
2018-03-22 21:27:23.525 (PP-Manager) Debug logging mask set to: NONE
2018-03-22 21:27:23.539 (PP-Manager) Domoticz Node Name is:domoticz02
2018-03-22 21:27:23.539 (PP-Manager) Domoticz Platform System is:Linux
2018-03-22 21:27:23.539 (PP-Manager) Default Python Version is:3.4.2.
2018-03-22 21:27:23.539 (PP-Manager) Collecting Updates for All Plugins!!!
2018-03-22 21:27:23.569 Error: (PP-Manager) Something went wrong with update of MoonPhases
2018-03-22 21:27:23.598 Error: (PP-Manager) Something went wrong with update of BatteryLevel
2018-03-22 21:27:23.598 (PP-Manager) Plugin:examples cannot be managed with PP-Manager!!.
2018-03-22 21:27:23.599 (PP-Manager) Plugin:AwoxSMP cannot be managed with PP-Manager!!.
2018-03-22 21:27:23.602 (Moon Phases) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE ALL
2018-03-22 21:27:23.602 (Moon Phases) 'Version':'1.0.3'
2018-03-22 21:27:23.602 (Moon Phases) 'Mode3':'cologne'
2018-03-22 21:27:23.602 (Moon Phases) 'HardwareID':'18'
2018-03-22 21:27:23.602 (Moon Phases) 'DomoticzHash':'927ba005'
2018-03-22 21:27:23.602 (Moon Phases) 'Mode2':'de'
2018-03-22 21:27:23.603 (Moon Phases) 'Mode4':'60'
2018-03-22 21:27:23.603 (Moon Phases) 'HomeFolder':'/home/pi/domoticz/plugins/MoonPhases/'
2018-03-22 21:27:23.603 (Moon Phases) 'Mode6':'Debug'
2018-03-22 21:27:23.603 (Moon Phases) 'Name':'Moon Phases'
2018-03-22 21:27:23.603 (Moon Phases) 'Key':'MoonPhases'
2018-03-22 21:27:23.603 (Moon Phases) 'Author':'ycahome ft. jackslayter'
2018-03-22 21:27:23.603 (Moon Phases) 'Port':'0'
2018-03-22 21:27:23.603 (Moon Phases) 'Mode1':'WU_API_KEY'
2018-03-22 21:27:23.603 (Moon Phases) 'DomoticzBuildTime':'2018-03-18 08:38:55'
2018-03-22 21:27:23.603 (Moon Phases) 'DomoticzVersion':'3.9052'
2018-03-22 21:27:23.603 (Moon Phases) Device count: 1
2018-03-22 21:27:23.603 (Moon Phases) Device: 1 - ID: 336, Name: 'Moon Phases - Status', nValue: 0, sValue: ''
2018-03-22 21:27:23.603 (Moon Phases) Device ID: '336'
2018-03-22 21:27:23.603 (Moon Phases) Device Name: 'Moon Phases - Status'
2018-03-22 21:27:23.603 (Moon Phases) Device nValue: 0
2018-03-22 21:27:23.603 (Moon Phases) Device sValue: ''
2018-03-22 21:27:23.603 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases6WG.zip'.
2018-03-22 21:27:23.615 (Moon Phases) Added icon: SH_MoonPhases6WG from file SH_MoonPhases6WG.zip
2018-03-22 21:27:23.615 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases4WG.zip'.
2018-03-22 21:27:23.626 (Moon Phases) Added icon: SH_MoonPhases4WG from file SH_MoonPhases4WG.zip
2018-03-22 21:27:23.626 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases3FQ.zip'.
2018-03-22 21:27:23.637 (Moon Phases) Added icon: SH_MoonPhases3FQ from file SH_MoonPhases3FQ.zip
2018-03-22 21:27:23.637 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases2WC.zip'.
2018-03-22 21:27:23.648 (Moon Phases) Added icon: SH_MoonPhases2WC from file SH_MoonPhases2WC.zip
2018-03-22 21:27:23.649 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases1NM.zip'.
2018-03-22 21:27:23.659 (Moon Phases) Added icon: SH_MoonPhases1NM from file SH_MoonPhases1NM.zip
2018-03-22 21:27:23.659 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases8WC.zip'.
2018-03-22 21:27:23.670 (Moon Phases) Added icon: SH_MoonPhases8WC from file SH_MoonPhases8WC.zip
2018-03-22 21:27:23.670 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases5FM.zip'.
2018-03-22 21:27:23.682 (Moon Phases) Added icon: SH_MoonPhases5FM from file SH_MoonPhases5FM.zip
2018-03-22 21:27:23.682 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases7LQ.zip'.
2018-03-22 21:27:23.694 (Moon Phases) Added icon: SH_MoonPhases7LQ from file SH_MoonPhases7LQ.zip
2018-03-22 21:27:23.694 (Moon Phases) Number of icons loaded = 8
2018-03-22 21:27:23.694 (Moon Phases) Icon 138 MoonPhases3FQ
2018-03-22 21:27:23.694 (Moon Phases) Icon 126 MoonPhases7LQ
2018-03-22 21:27:23.694 (Moon Phases) Icon 129 MoonPhases6WG
2018-03-22 21:27:23.694 (Moon Phases) Icon 127 MoonPhases8WC
2018-03-22 21:27:23.694 (Moon Phases) Icon 132 MoonPhases5FM
2018-03-22 21:27:23.694 (Moon Phases) Icon 136 MoonPhases2WC
2018-03-22 21:27:23.694 (Moon Phases) Icon 139 MoonPhases4WG
2018-03-22 21:27:23.694 (Moon Phases) Icon 135 MoonPhases1NM
2018-03-22 21:27:23.694 (Moon Phases) Using polling interval of 60 minutes
2018-03-22 21:27:23.826
2018-03-22 21:27:23.901 subtype = Interface Response
Sequence nbr = 2
response on cmnd = Get Status
Transceiver type = 433.92MHz
Firmware version = 1015
Firmware type = Ext
Hardware version = 1.3
Undec off
X10 enabled
ARC disabled
AC enabled
HomeEasy EU enabled
Meiantech/Atlantic disabled
Oregon Scientific enabled
ATI/Cartelectronic disabled
Visonic disabled
Mertik disabled
AD disabled
Hideki enabled
La Crosse enabled
FS20/Legrand disabled
ProGuard disabled
BlindsT0 disabled
BlindsT1 disabled
AE disabled
RUBiCSON enabled
FineOffset disabled
Lighting4 enabled
Conrad RSL disabled
ByronSX disabled
IMAGINTRONIX disabled
KEELOQ disabled
Home Confort disabled
2018-03-22 21:27:24.247 Fritzbox: connected to: 192.168.6.2:1012
2018-03-22 21:27:24.481 Harmony Hub: Authentication successful
2018-03-22 21:27:24.513 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:24.526 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:25.532 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:25.545 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:26.374 (RFXCOM) Temp + Humidity (Wohnzimmer)
2018-03-22 21:27:26.512 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:26.525 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:28.994 MQTT: Topic: domoticz/in, Message: {"idx":295,"nvalue":0,"svalue":"20.9;54.9;1"}
2018-03-22 21:27:32.630 (Wetter Köln) Temp + Humidity + Baro (Wetter Köln)
2018-03-22 21:27:32.631 (Wetter Köln) Wind (Wind Köln)
2018-03-22 21:27:32.633 (Wetter Köln) UV (UV Köln)
2018-03-22 21:27:32.639 (Wetter Köln) Rain (Regen)
2018-03-22 21:27:32.642 (Wetter Köln) General/Visibility (Sicht Köln)
2018-03-22 21:27:32.723 (Wetter Weiden) Temp + Humidity + Baro (Müngersdorf)
2018-03-22 21:27:32.731 (Wetter Weiden) Wind (Wind)
2018-03-22 21:27:32.736 (Wetter Weiden) UV (UV)
2018-03-22 21:27:32.738 (Wetter Weiden) Rain (Unknown)
2018-03-22 21:27:32.740 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_sensorWU.lua
2018-03-22 21:27:32.744 (Wetter Weiden) General/Visibility (Sicht)
2018-03-22 21:27:32.938 (Moon Phases) pushing 'onHeartbeatCallback' on to queue
2018-03-22 21:27:32.953 (Moon Phases) processing 'onHeartbeatCallback' message
2018-03-22 21:27:32.953 (Moon Phases) Calling message handler 'onHeartbeat'.
2018-03-22 21:27:32.953 (Moon Phases) onStop called
2018-03-22 21:27:33.346 (Moon Phases) Moon URL:http://api.wunderground.com/api/WU_API_KEY/astronomy/q/de/cologne.json
2018-03-22 21:27:33.346 Error: (Moon Phases) 'onHeartbeat' failed 'KeyError'.
2018-03-22 21:27:33.346 Error: (Moon Phases) ----> Line 183 in /home/pi/domoticz/plugins/MoonPhases/plugin.py, function onHeartbeat
2018-03-22 21:27:33.346 Error: (Moon Phases) ----> Line 120 in /home/pi/domoticz/plugins/MoonPhases/plugin.py, function onHeartbeat
2018-03-22 21:27:35.286 MQTT: Topic: domoticz/in, Message: {"idx":319,"nvalue":0,"svalue":"64;38907.4"}
2018-03-22 21:27:36.057 (RFXCOM) Temp + Humidity (Schlafzimmer)
2018-03-22 21:27:37.404 MQTT: Topic: domoticz/in, Message: {"idx":296,"nvalue":1,"svalue":""}
2018-03-22 21:27:39.182 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:39.195 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:39.233 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:39.261 (Aeotec Z-Stick Gen5) Usage (Unknown)
2018-03-22 21:27:39.274 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:39.455 (Aeotec Z-Stick Gen5) Thermostat (Thermostat Küche)
2018-03-22 21:27:39.559 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:39.565 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:39.648 (Aeotec Z-Stick Gen5) Thermostat (Thermostat Küche Eco)
2018-03-22 21:27:40.382 (Aeotec Z-Stick Gen5) Temp (Temperature)
2018-03-22 21:27:40.578 Warning: Notification NOT handled (type: F3 - General, subtype: 20 - Thermostat Mode), please report on GitHub!
2018-03-22 21:27:40.579 (Aeotec Z-Stick Gen5) General/Thermostat Mode (Thermostat Mode Küche)
2018-03-22 21:27:40.677 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:40.689 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:40.761 (Aeotec Z-Stick Gen5) Light/Switch (Alarm Type)
2018-03-22 21:27:40.765 (Aeotec Z-Stick Gen5) Light/Switch (Alarm Level)
2018-03-22 21:27:40.768 (Aeotec Z-Stick Gen5) General/Alarm (Alarm Type: Power Management 8 (0x08))
2018-03-22 21:27:40.773 (Aeotec Z-Stick Gen5) Light/Switch (Power Management)
2018-03-22 21:27:40.851 (RFXCOM) Temp + Humidity (Jenne)
2018-03-22 21:27:40.935 (Aeotec Z-Stick Gen5) Light/Switch (Alarm Type)
2018-03-22 21:27:40.939 (Aeotec Z-Stick Gen5) Light/Switch (Alarm Level)
2018-03-22 21:27:40.941 (Aeotec Z-Stick Gen5) General/Alarm (Alarm Type: System 9 (0x09))
2018-03-22 21:27:40.946 (Aeotec Z-Stick Gen5) Light/Switch (System)
2018-03-22 21:27:41.121 OpenZWave: Awake Nodes queried
2018-03-22 21:27:41.515 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:41.527 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:42.940 (Moon Phases) pushing 'onHeartbeatCallback' on to queue
2018-03-22 21:27:42.967 (Moon Phases) processing 'onHeartbeatCallback' message
2018-03-22 21:27:42.967 (Moon Phases) Calling message handler 'onHeartbeat'.
2018-03-22 21:27:42.968 (Moon Phases) onStop called
2018-03-22 21:27:43.515 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:43.527 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:44.420 MQTT: Topic: domoticz/in, Message: {"idx":297,"nvalue":0,"svalue":"55;50254.6"}
2018-03-22 21:27:46.832 MQTT: Topic: domoticz/in, Message: {"idx":316,"nvalue":1,"svalue":""}
2018-03-22 21:27:47.195 (RFXCOM) Temp + Humidity (Badezimmer)
2018-03-22 21:27:52.942 (Moon Phases) pushing 'onHeartbeatCallback' on to queue
2018-03-22 21:27:52.943 (Moon Phases) processing 'onHeartbeatCallback' message
2018-03-22 21:27:52.943 (Moon Phases) Calling message handler 'onHeartbeat'.
2018-03-22 21:27:52.943 (Moon Phases) onStop called
2018-03-22 21:27:53.744 MQTT: Topic: domoticz/in, Message: {"idx":317,"nvalue":0,"svalue":"57;34607.1"}
2018-03-22 21:27:56.702 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:56.714 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:56.730 (Aeotec Z-Stick Gen5) Usage (Verbrauch Espressomaschine)
2018-03-22 21:27:56.743 (Aeotec Z-Stick Gen5) General/kWh (kWh Espressomaschine)
2018-03-22 21:27:56.846 (Aeotec Z-Stick Gen5) Thermostat (Thermostat Küche)
2018-03-22 21:27:57.147 (RFXCOM) Temp + Humidity (Flur)
Thanks,
Sascha

Re: Python Plugin: MoonPhases

Posted: Thursday 22 March 2018 21:57
by ycahome
it seems that wunderground does not provide valid data for Cologne,DE.

try to access
http://api.wunderground.com/api/YOUR_KE ... logne.json
and
http://api.wunderground.com/api/YOUR_KE ... logne.json

to see the difference.

Also, you have another instance with your KEY on logs. Please remove it.

Re: Python Plugin: MoonPhases

Posted: Thursday 22 March 2018 22:05
by ycahome
Found a workaround.

try "Germany" instead of "DE"

Re: Python Plugin: MoonPhases

Posted: Thursday 22 March 2018 22:10
by brainpaincgn
It's working! Fantastic!

Thanks a lot!

S.

Re: Python Plugin: MoonPhases

Posted: Friday 23 March 2018 0:01
by fubar
Glad you fixed the parameters

The log also shows a problem I've fixed in my repository and included in a pull request @ https://github.com/ycahome/MoonPhases/pull/3

Code: Select all

2018-03-22 21:27:23.603 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases6WG.zip'.
2018-03-22 21:27:23.615 (Moon Phases) Added icon: SH_MoonPhases6WG from file SH_MoonPhases6WG.zip
2018-03-22 21:27:23.615 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases4WG.zip'.
2018-03-22 21:27:23.626 (Moon Phases) Added icon: SH_MoonPhases4WG from file SH_MoonPhases4WG.zip
2018-03-22 21:27:23.626 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases3FQ.zip'.
2018-03-22 21:27:23.637 (Moon Phases) Added icon: SH_MoonPhases3FQ from file SH_MoonPhases3FQ.zip
2018-03-22 21:27:23.637 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases2WC.zip'.
2018-03-22 21:27:23.648 (Moon Phases) Added icon: SH_MoonPhases2WC from file SH_MoonPhases2WC.zip
2018-03-22 21:27:23.649 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases1NM.zip'.
2018-03-22 21:27:23.659 (Moon Phases) Added icon: SH_MoonPhases1NM from file SH_MoonPhases1NM.zip
2018-03-22 21:27:23.659 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases8WC.zip'.
2018-03-22 21:27:23.670 (Moon Phases) Added icon: SH_MoonPhases8WC from file SH_MoonPhases8WC.zip
2018-03-22 21:27:23.670 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases5FM.zip'.
2018-03-22 21:27:23.682 (Moon Phases) Added icon: SH_MoonPhases5FM from file SH_MoonPhases5FM.zip
2018-03-22 21:27:23.682 (Moon Phases) Creating images from file '/home/pi/domoticz/plugins/MoonPhases/SH_MoonPhases7LQ.zip'.
2018-03-22 21:27:23.694 (Moon Phases) Added icon: SH_MoonPhases7LQ from file SH_MoonPhases7LQ.zip
2018-03-22 21:27:23.694 (Moon Phases) Number of icons loaded = 8
2018-03-22 21:27:23.694 (Moon Phases) Icon 138 MoonPhases3FQ
2018-03-22 21:27:23.694 (Moon Phases) Icon 126 MoonPhases7LQ
2018-03-22 21:27:23.694 (Moon Phases) Icon 129 MoonPhases6WG
2018-03-22 21:27:23.694 (Moon Phases) Icon 127 MoonPhases8WC
2018-03-22 21:27:23.694 (Moon Phases) Icon 132 MoonPhases5FM
2018-03-22 21:27:23.694 (Moon Phases) Icon 136 MoonPhases2WC
2018-03-22 21:27:23.694 (Moon Phases) Icon 139 MoonPhases4WG
2018-03-22 21:27:23.694 (Moon Phases) Icon 135 MoonPhases1NM
2018-03-22 21:27:23.694 (Moon Phases) Using polling interval of 60 minutes
Only 8 icons are being loaded - there should be 16 - 8 for each hemisphere. It seems there's something fishy with Domoticz and/or the python API wrapper in handling image zips and names containing underscores.

The pull request will change them all to remove the underscores - using the updated code, everything works right for me.

Re: Python Plugin: MoonPhases

Posted: Friday 11 May 2018 20:50
by toutazimuth
Hi ycahome
Everything is great for me with your MoonPhases plugin.
Domoticz beta 9424, Pi3B, and Python3.4.
Thx a lot ;)

Re: Python Plugin: MoonPhases

Posted: Sunday 13 May 2018 7:25
by manutremo
Just wanted to say that it's just installed and working great over here, many thanks!

Re: Python Plugin: MoonPhases

Posted: Sunday 13 May 2018 7:49
by manutremo
Just wanted to add a comment and a question after getting it to work:

- The name of the city I live at has two words with an space in between. In the hardware configuration that didn't work correctly, I had to substitue the space with %20 to make it work.

- What's the point of a 60 minutes polling interval for this plugin. Would it make sense to increase that to once per day (1440min) since the data it's collecting (moon phase) wouldn't be expected to change more often than that? Or am I missing something?

Re: Python Plugin: MoonPhases

Posted: Tuesday 22 May 2018 9:05
by ycahome
manutremo wrote: Sunday 13 May 2018 7:49 Just wanted to add a comment and a question after getting it to work:

- The name of the city I live at has two words with an space in between. In the hardware configuration that didn't work correctly, I had to substitue the space with %20 to make it work.

- What's the point of a 60 minutes polling interval for this plugin. Would it make sense to increase that to once per day (1440min) since the data it's collecting (moon phase) wouldn't be expected to change more often than that? Or am I missing something?
Hello manutremo.

#1. You are right about the space between. This is a problem on URL Query also, not only on python plugin. If you try to access with a browse you will face the same problem.

#2. 60 mins is the default interval for this plugin. You can change it. We have to deal also with Domoticz's intention to timeout and mark sensors as offline.

Re: Python Plugin: MoonPhases

Posted: Friday 21 September 2018 8:00
by Tonio16
Hello

Is there a plan to update the plugin to be indepandant of WU? WU service is going to change at the end of this year and I unterstood correctly for ney user, it will be not possible to use the plugin.

Regards

Antoine

Re: Python Plugin: MoonPhases

Posted: Friday 21 September 2018 8:19
by ycahome
Tonio16 wrote: Friday 21 September 2018 8:00 Hello

Is there a plan to update the plugin to be indepandant of WU? WU service is going to change at the end of this year and I unterstood correctly for ney user, it will be not possible to use the plugin.

Regards

Antoine
Hello Tonio16.

If the service changes, then, plugin will need to upgrade its code to use the new service.
Unfortunately I don't know how many users have this plugin (in the past I ve tried to write an online user count for plugins but never finished) and if worth the effort. Lets see what will happen with WU.

As for the functionality without WU, never thought about this possibility. Do you have an idea?

Re: Python Plugin: MoonPhases

Posted: Thursday 07 March 2019 15:44
by FireWizard
Since WU discontinued the free API keys some days ago, this python script stopped working too.
Any plans to update your script to use e.g. Darksky?
See: https://darksky.net/dev/docs

Re: Python Plugin: MoonPhases

Posted: Friday 08 March 2019 20:43
by aleph0
Since you're using python, you don't really need an external service to get moon status. Have a look at pyephem, it enable to calculate everything you need about the moon locally, and much more

Envoyé de mon Hi9Air en utilisant Tapatalk


Re: Python Plugin: MoonPhases

Posted: Saturday 09 March 2019 14:27
by FireWizard
I agree you can calculate everything yourself if you use pyephem. I have considered it as well, but pyephem is deprecated.
It claims that it will not disappear and continue to receive critical bug fixes. However I wonder if it would be wise to start a development with help of a library , which is deprecated.. On the other hand, as long as it works, it works.
There seems to be an alternative library also, Anyone tried that already?

Re: Python Plugin: MoonPhases

Posted: Tuesday 10 September 2019 16:18
by Jackb
I've created a new MoonPhase dzEvents script that does not use Weather Underground but HERE, which is a free astronomy API.

For more info:
https://github.com/JoopIdema/Domoticz-MoonPhases

Re: Python Plugin: MoonPhases

Posted: Saturday 11 April 2020 8:57
by naitsirhc
Hi,

I tried several codes (java script/Rest and OAuth) but it doesn't seem to work.
2020-04-11 08:49:02.929 Error: dzVents: Error: (3.0.2) Moon: HTTP/1.1 response: 401 ==>> Unauthorized
Do I have to create another API key?

many thanks

Edit:
Did find the clue. You have to create an app code and ID at the Android / Apple section. Then it works

Re: Python Plugin: MoonPhases

Posted: Tuesday 21 September 2021 16:28
by timmpo
I changed some line in the plugin to work without the need of an online API, you can even run it offline.
It uses the pylunar library instead.
I have only put an hour in this so some bugs are expected :)

Install libary: pip3 install pylunar

Find your cordinates https://www.countrycoordinate.com/

plugin.py

Code: Select all


"""
MoonPhases Plugin

Author: Ycahome, 2017 CREDITS TO jackslayter

Version:    1.0.0: Initial Release
Version:    1.0.1: Southern hemisphere moon images
Version:    1.0.4: Changed icon/zip names to avoid underscores - something fishy in domoticz images or the python api

"""

"""
<plugin key="MoonPhases" name="Moon Phases" author="ycahome ft. jackslayter"
  version="1.0.0" wikilink="http://www.domoticz.com/wiki/plugins/"
  externallink="http://www.domoticz.com/forum/viewtopic.php?f=65&t=21993">
     <description>
        <p>This is a edited version of the orginal plugin, it uses the pylunar libary instead of the api</p>
        <p>https://pypi.org/project/pylunar/</p>
        <p>pip3 install pylunar</p>
        <p>find your cordinates https://www.countrycoordinate.com/ </p>
     </description>
     <params>
        <param field="Mode1" label="Latitude (DMS)" width="100px" required="true" default="58, 32, 16"/>
        <param field="Mode2" label="Longitude (DMS)" width="100px" required="true" default="15, 2, 49"/>
        <param field="Mode4" label="Polling interval (minutes)" width="40px" required="true" default="60"/>
        <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.request
import json
from datetime import datetime
from datetime import timedelta
from datetime import date
import time
import sys
sys.path.append('/home/pi/.local/lib/python3.7/site-packages')
import pylunar

icons = {"MoonPhases1NM": "MoonPhases1NM.zip",
         "MoonPhases2WC": "MoonPhases2WC.zip",
         "MoonPhases3FQ": "MoonPhases3FQ.zip",
         "MoonPhases4WG": "MoonPhases4WG.zip",
         "MoonPhases5FM": "MoonPhases5FM.zip",
         "MoonPhases6WG": "MoonPhases6WG.zip",
         "MoonPhases7LQ": "MoonPhases7LQ.zip",
         "MoonPhases8WC": "MoonPhases8WC.zip",
         "MoonPhases1NMSH": "MoonPhases1NMSH.zip",
         "MoonPhases2WCSH": "MoonPhases2WCSH.zip",
         "MoonPhases3FQSH": "MoonPhases3FQSH.zip",
         "MoonPhases4WGSH": "MoonPhases4WGSH.zip",
         "MoonPhases5FMSH": "MoonPhases5FMSH.zip",
         "MoonPhases6WGSH": "MoonPhases6WGSH.zip",
         "MoonPhases7LQSH": "MoonPhases7LQSH.zip",
         "MoonPhases8WCSH": "MoonPhases8WCSH.zip"}


class BasePlugin:

    def __init__(self):
        self.debug = False
        self.nextupdate = datetime.now()
        self.pollinterval = 60  # default polling interval in minutes
        self.error = False
        self.southern_hemi = False
        self.suffix= 'SH'
        self.reload = True
        return

    def onStart(self):
        Domoticz.Debug("onStart called")
        global icons
        if Parameters["Mode6"] == 'Debug':
            self.debug = True
            Domoticz.Debugging(1)
            DumpConfigToLog()
        else:
            Domoticz.Debugging(0)

        # load custom MoonPhase 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="Status", Unit=1, TypeName="Custom",Options={"Custom": "1;Days"},Used=1).Create()
        # check polling interval parameter
        try:
            temp = int(Parameters["Mode4"])
        except:
            Domoticz.Error("Invalid polling interval parameter")
        else:
            if temp < 60:
                temp = 60  # minimum polling interval
                Domoticz.Error("Specified polling interval too short: changed to 60 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):
        Domoticz.Debug("onStop called")
        now = datetime.now()
        if now >= self.nextupdate:
            self.nextupdate = now + timedelta(minutes=self.pollinterval)
            
            # Conversion of values to match this script
            longditude = Parameters["Mode1"].split(',')
            latitude = Parameters["Mode2"].split(',')
            Domoticz.Debug(longditude[1])
            mi = pylunar.MoonInfo((longditude[0], longditude[1], longditude[2]) ,(latitude[0],latitude[1],latitude[2]))
            today = date.today()
            now = datetime.now()
            mi.update((today.year, today.month, today.day, now.hour, now.minute, now.second))
            phase_percent = int(round(mi.fractional_phase(),2)*100)
            lune = mi.phase_name()
            
            if lune == "WAXING_GIBBOUS":
                lune = "Waxing Gibbous"
            elif lune == "NEW_MOON":
                lune = "New Moon"
            elif lune == "WAXING_CRESCENT":
                lune = "Waxing Crescent"
            elif lune == "FIRST_QUARTER":
                lune = "First Quarter"
            elif lune == "FULL_MOON":
                lune = "Full"
            elif lune == "WANING_GIBBOUS":
                lune = "Waning Gibbous"
            elif lune == "LAST_QUARTER":
                lune = "Last Quarter"
            elif lune == "WANING_CRESCENT":
                lune = "Waning Crescent"
            
            luneage = round(mi.age())
            Domoticz.Log("Moon Phase:"+str(lune))
            Domoticz.Log("Moon Age:"+str(luneage))
            self.UpdateDevice(lune,luneage,phase_percent)



    def UpdateDevice(self, lune, luneage, phase_percent):
        Domoticz.Debug("UpdateDevice called")
        # Make sure that the Domoticz device still exists (they can be deleted) before updating it
        datafr = ""
        if 1 in Devices:
            if lune == "New Moon":
                datafr = "MoonPhases1NM"
                phase = 1
            elif lune == "Waxing Crescent":
                datafr = "MoonPhases2WC"
                phase = 2
            elif lune == "First Quarter":
                datafr = "MoonPhases3FQ"
                phase = 3
            elif lune == "Waxing Gibbous":
                datafr = "MoonPhases4WG"
                phase = 4
            elif lune == "Full":
                datafr = "MoonPhases5FM"
                phase = 5
            elif lune == "Waning Gibbous":
                datafr = "MoonPhases6WG"
                phase = 6
            elif lune == "Last Quarter":
                datafr = "MoonPhases7LQ"
                phase = 7
            elif lune == "Waning Crescent":
                datafr = "MoonPhases8WC"
                phase = 8

            try:
               x = lune
               y = phase_percent
               z = str(x) + " " + str(y) + "%"
               Devices[1].Update(nValue=0, Name=z, sValue=str(luneage), Image=Images[datafr].ID)
               Devices[1].Update(nValue=0, sValue=str(luneage), Image=Images[datafr].ID)
            except Exception as e:
               Domoticz.Error(e)
               Domoticz.Error("Failed to update device unit 1 with values %s:%s:" % lune, luneage)

        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

Re: Python Plugin: MoonPhases

Posted: Tuesday 21 September 2021 17:11
by waltervl
timmpo wrote: Tuesday 21 September 2021 16:28 I changed some line in the plugin to work without the need of an online API, you can even run it offline.
Great work i think. Always better to not using an external site if not needed.
Perhaps create a PR on the github repository so everybody gets the latest version after install or update with git pull