Browse Source

Coordinates extracted to config.py

master
Dirk Alders 2 years ago
parent
commit
65bfc63fc4
2 changed files with 8 additions and 7 deletions
  1. 3
    0
      examples/config.py
  2. 5
    7
      piface_function.py

+ 3
- 0
examples/config.py View File

1
 #!/usr/bin/env python
1
 #!/usr/bin/env python
2
 # -*- coding: UTF-8 -*-
2
 # -*- coding: UTF-8 -*-
3
+import geo
3
 import os
4
 import os
4
 import report
5
 import report
5
 
6
 
8
 MQTT_SERVER = "host"
9
 MQTT_SERVER = "host"
9
 MQTT_TOPIC = "leyk"
10
 MQTT_TOPIC = "leyk"
10
 
11
 
12
+GEO_POSITION = geo.gps.coordinate(lat=49.519167, lon=9.3672222)
13
+
11
 #
14
 #
12
 # Logging
15
 # Logging
13
 #
16
 #

+ 5
- 7
piface_function.py View File

22
     ROOT_LOGGER_NAME = 'root'
22
     ROOT_LOGGER_NAME = 'root'
23
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
23
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
24
 
24
 
25
-geo_position = geo.gps.coordinate(lat=49.976596, lon=9.1481443)
26
-
27
 
25
 
28
 class pi_face(object):
26
 class pi_face(object):
29
     LOG_PREFIX = 'PiFace:'
27
     LOG_PREFIX = 'PiFace:'
237
             return time.mktime(time.struct_time(tm))
235
             return time.mktime(time.struct_time(tm))
238
     
236
     
239
         def sunrise_time():
237
         def sunrise_time():
240
-            return time.mktime(geo.sun.sunrise(geo_position)) + 30 * 60
238
+            return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + 30 * 60
241
     
239
     
242
         def sunset_time():
240
         def sunset_time():
243
-            return time.mktime(geo.sun.sunset(geo_position)) - 30 * 60
241
+            return time.mktime(geo.sun.sunset(config.GEO_POSITION)) - 30 * 60
244
     
242
     
245
         def sleep_time():
243
         def sleep_time():
246
             tm = time.localtime()
244
             tm = time.localtime()
286
         return not self.sm_mode.this_state_is(self.sm_mode.STATE_AUTOMATIC)
284
         return not self.sm_mode.this_state_is(self.sm_mode.STATE_AUTOMATIC)
287
 
285
 
288
     def report_sunset_sunrise(self):
286
     def report_sunset_sunrise(self):
289
-        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))
287
+        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))
290
 )
288
 )
291
 
289
 
292
 
290
 
479
         return time.mktime(time.struct_time(tm))
477
         return time.mktime(time.struct_time(tm))
480
 
478
 
481
     def sunrise_time(self):
479
     def sunrise_time(self):
482
-        return time.mktime(geo.sun.sunrise(geo_position)) + 30 * 60
480
+        return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + 30 * 60
483
 
481
 
484
     def sunset_time(self):
482
     def sunset_time(self):
485
-        return time.mktime(geo.sun.sunset(geo_position)) - 30 * 60
483
+        return time.mktime(geo.sun.sunset(config.GEO_POSITION)) - 30 * 60
486
 
484
 
487
     def sleep_time(self):
485
     def sleep_time(self):
488
         tm = time.localtime()
486
         tm = time.localtime()

Loading…
Cancel
Save