Example #1
0
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
Example #2
0
def proc_newsPub(items, sHHMM):
	clsPub=com_mqttPub.mqttPubClass()
	for item in items:
		#print( "item="+ item)
		clsPub.send_pubw(item ,mTopic)
Example #3
0
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 )
Example #4
0
def proc_pub(items):
	clsPub=com_mqttPub.mqttPubClass()
	for item in items:
		clsPub.send_pubw(item ,mTopic)