コード例 #1
0
ファイル: pikoToHM.py プロジェクト: lucasHSA/piko
logger.addHandler(ch)
logger.addHandler(fh)

PIKO_INTERVAL = 30 # seconds
OWM_INTERVAL = 1800 # seconds
HM_PV_REMAINING_POWER_ID = 12772
HM_PV_STRING_1_POWER_ID = 15241
HM_PV_STRING_2_POWER_ID = 15242
HM_WEATHER_FORECAST_CLOUDS_ID = 20144
HM_WEATHER_CURRENT_TEMPERATURE_ID = 21442
HM_WEATHER_FORECAST_TEMPERATURE_ID = 21443
OWM_API_KEY = 'insert'
OWM_CITY_ID = 2835477

logging.info('Started')
p = Piko(host='http://192.168.178.123')
hm = HM('http://192.168.178.49')
owm = OWM(OWM_API_KEY)
last_weather_update = time.time() - OWM_INTERVAL # - OWM_INTERVAL to update on first run


while(True):
    try:
        # -------------------------------
        # Weather
        now = time.time()
        if (now - last_weather_update) >= OWM_INTERVAL:
            try:

                # Queries the OWM web API for three hours weather forecast for the specified city ID. 
                # A Forecaster object is returned, containing a Forecast instance covering a global streak of five days: