def get_wdata(sCity): sPay="" clsConst = com_appConst.appConstClass() clsWeaher= com_weather.weatherClass() clsPub=com_mqttPub.mqttPubClass() dic= clsWeaher.get_wdata(sCity) print(len(dic)) print(dic) if (len(dic) < 1): return #city clsPub.send_pubw(dic["city"] ,mTopic) #cond clsPub.send_pubw(dic["cond"] ,mTopic) #temp-H print("temp_H=") print(str(dic["temp_H"])) sTemp="High Temp:" + str(dic["temp_H"]) + "(C)" clsPub.send_pubw(sTemp ,mTopic) #temp-L sTemp="Low Temp:" + str(dic["temp_L"]) + "(C)" clsPub.send_pubw(sTemp ,mTopic) return
, 3: "800080" # purple , 4: "008000" #green , 5: "ffff00" #Yellow , 6: "000080" #navy , 7: "00ffff" #aqua , 8: "404040" #white } if __name__ == "__main__": clsPub = com_mqttPub.mqttPubClass() from datetime import datetime tmBef = datetime.now() while True: tmNow = datetime.now() tmSpan = tmNow - tmBef iSpan = tmSpan.total_seconds() time.sleep(1.0) sTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") sTemp = "" print("time=" + sTime) if iSpan > mTimeMax: tmBef = datetime.now() try: sRGB = pattern[mCount] mCount = mCount + 1
def proc_newsPub(items, sHHMM): clsPub=com_mqttPub.mqttPubClass() for item in items: #print( "item="+ item) clsPub.send_pubw(item ,mTopic)
import datetime import time import sys import traceback import com_appConst import com_color import com_mqttPub mTopic="item-kuc-arc-f/device-1/rgb_led_2" mTimeMax=5 mMcid=1 mCtColor=0 if __name__ == "__main__": clsPub=com_mqttPub.mqttPubClass() clsColor = com_color.colorClass() from datetime import datetime tmBef = datetime.now() while True: tmNow = datetime.now() tmSpan = tmNow - tmBef iSpan = tmSpan.total_seconds() time.sleep(1.0) sTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") sTemp="" print("time=" +sTime) if iSpan > mTimeMax: tmBef = datetime.now() try: items = clsColor.get_colorData( mMcid )
def proc_pub(items): clsPub=com_mqttPub.mqttPubClass() for item in items: clsPub.send_pubw(item ,mTopic)