示例#1
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from PyQt4 import QtGui

from hm import HM

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    hm = HM()
    hm.show()
    sys.exit(app.exec_())

示例#2
0
文件: pikoToHM.py 项目: lucasHSA/piko
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: 
                # this instance encapsulates Weather objects, with a time interval of three hours one from each other