Coordinates extracted to config.py

This commit is contained in:
Dirk Alders 2022-09-13 07:40:55 +02:00
parent 0e2a063bd1
commit 65bfc63fc4
2 changed files with 8 additions and 7 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
import geo
import os import os
import report import report
@ -8,6 +9,8 @@ MQTT_PASS = "password"
MQTT_SERVER = "host" MQTT_SERVER = "host"
MQTT_TOPIC = "leyk" MQTT_TOPIC = "leyk"
GEO_POSITION = geo.gps.coordinate(lat=49.519167, lon=9.3672222)
# #
# Logging # Logging
# #

View File

@ -22,8 +22,6 @@ except ImportError:
ROOT_LOGGER_NAME = 'root' ROOT_LOGGER_NAME = 'root'
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__) logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
geo_position = geo.gps.coordinate(lat=49.976596, lon=9.1481443)
class pi_face(object): class pi_face(object):
LOG_PREFIX = 'PiFace:' LOG_PREFIX = 'PiFace:'
@ -237,10 +235,10 @@ class state_machine_day_state(state_machine.state_machine):
return time.mktime(time.struct_time(tm)) return time.mktime(time.struct_time(tm))
def sunrise_time(): 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(): 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(): def sleep_time():
tm = time.localtime() 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) return not self.sm_mode.this_state_is(self.sm_mode.STATE_AUTOMATIC)
def report_sunset_sunrise(self): 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)) return time.mktime(time.struct_time(tm))
def sunrise_time(self): 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): 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): def sleep_time(self):
tm = time.localtime() tm = time.localtime()