2022-12-23 10:00:09 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2022-12-26 09:53:48 +01:00
|
|
|
import config
|
|
|
|
import geo
|
2022-12-23 10:00:09 +01:00
|
|
|
import inspect
|
2022-12-26 09:53:48 +01:00
|
|
|
import time
|
2022-12-23 10:00:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
class changed_value_indicator(dict):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__(self)
|
|
|
|
|
|
|
|
def changed_here(self, topic, key, value):
|
|
|
|
caller_name = inspect.getmodule(inspect.stack()[1][0]).__name__ + '.' + inspect.stack()[1][3]
|
|
|
|
key = '::'.join([caller_name, topic, key])
|
|
|
|
#
|
|
|
|
rv = self.get(key) != value
|
|
|
|
self[key] = value
|
|
|
|
return rv
|
2022-12-26 09:53:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
def now():
|
|
|
|
return time.mktime(time.localtime())
|
|
|
|
|
|
|
|
|
|
|
|
def sunrise_time(time_offs_min=30):
|
|
|
|
return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + time_offs_min * 60
|
|
|
|
|
|
|
|
|
|
|
|
def sunset_time(time_offs_min=-30):
|
|
|
|
return time.mktime(geo.sun.sunset(config.GEO_POSITION)) + time_offs_min * 60
|