From 65bfc63fc4d2ec368560d7cc102e324f5d0309ae Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Tue, 13 Sep 2022 07:40:55 +0200 Subject: [PATCH] Coordinates extracted to config.py --- examples/config.py | 3 +++ piface_function.py | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/config.py b/examples/config.py index 3bf6604..57c2f0d 100644 --- a/examples/config.py +++ b/examples/config.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # -*- coding: UTF-8 -*- +import geo import os import report @@ -8,6 +9,8 @@ MQTT_PASS = "password" MQTT_SERVER = "host" MQTT_TOPIC = "leyk" +GEO_POSITION = geo.gps.coordinate(lat=49.519167, lon=9.3672222) + # # Logging # diff --git a/piface_function.py b/piface_function.py index a421844..9759a7f 100644 --- a/piface_function.py +++ b/piface_function.py @@ -22,8 +22,6 @@ except ImportError: ROOT_LOGGER_NAME = 'root' logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__) -geo_position = geo.gps.coordinate(lat=49.976596, lon=9.1481443) - class pi_face(object): LOG_PREFIX = 'PiFace:' @@ -237,10 +235,10 @@ class state_machine_day_state(state_machine.state_machine): return time.mktime(time.struct_time(tm)) def sunrise_time(): - return time.mktime(geo.sun.sunrise(geo_position)) + 30 * 60 + return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + 30 * 60 def sunset_time(): - return time.mktime(geo.sun.sunset(geo_position)) - 30 * 60 + return time.mktime(geo.sun.sunset(config.GEO_POSITION)) - 30 * 60 def sleep_time(): tm = time.localtime() @@ -286,7 +284,7 @@ class state_machine_day_state(state_machine.state_machine): return not self.sm_mode.this_state_is(self.sm_mode.STATE_AUTOMATIC) def report_sunset_sunrise(self): - state_machine.logger.debug('Sunrise: %s - Sunset: %s;', time.strftime("%H:%M", geo.sun.sunrise(geo_position)), time.strftime("%H:%M", geo.sun.sunset(geo_position)) + state_machine.logger.debug('Sunrise: %s - Sunset: %s;', time.strftime("%H:%M", geo.sun.sunrise(config.GEO_POSITION)), time.strftime("%H:%M", geo.sun.sunset(config.GEO_POSITION)) ) @@ -479,10 +477,10 @@ class leyk(object): return time.mktime(time.struct_time(tm)) def sunrise_time(self): - return time.mktime(geo.sun.sunrise(geo_position)) + 30 * 60 + return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + 30 * 60 def sunset_time(self): - return time.mktime(geo.sun.sunset(geo_position)) - 30 * 60 + return time.mktime(geo.sun.sunset(config.GEO_POSITION)) - 30 * 60 def sleep_time(self): tm = time.localtime()