def __init__(self): self.debug = False self.oh = openhab() self.azimuth = float(self.oh.getState('Sun_Azimuth')) self.elevation = float(self.oh.getState('Sun_Elevation')) self.sunrise_azimuth = float(self.oh.getState('Sunrise_Azimuth')) self.sunset_azimuth = float(self.oh.getState('Sunset_Azimuth')) ts = time.time() utc_offset = (datetime.fromtimestamp(ts) - datetime.utcfromtimestamp(ts)).total_seconds()/3600 for h in xrange(0,24,HOURS): t = datetime.combine(date.today(), datetime.min.time()) + timedelta(hours=-utc_offset+h-24) a = self.oh.getStateHistoryFromInflux('Sun_Azimuth',t.strftime('%Y-%m-%dT%H:%M:%S') + 'Z') if (a == None): a = 0 DEGS.extend([a])
def __init__(self): self.debug = True self.oh = openhab() self.client_id = self.oh.getState('spotify_client_id') self.client_secret = self.oh.getState('spotify_client_secret') self.access_token = self.oh.getState('spotify_access_token') self.refresh_token = self.oh.getState('spotify_refresh_token') self.token_issued = self.oh.getState('spotify_token_issued') self.token_expiry = self.oh.getState('spotify_token_expiry') if (self.token_expiry == "NULL"): self.refreshCredentials() if (self.access_token == "NULL"): self.generateCredentials() else: if (time.time() > float(self.token_expiry)): self.refreshCredentials()
def __init__(self): self.debug = True self.oh = openhab() self.loadCredentials()