def lalala(message): global previous if message.chat.type == 'private': if message.text == 'Погода': bot.send_message(message.chat.id, "Выберите город", reply_markup=keyboard_for_weather()) elif message.text == 'Калькулятор': bot.send_message(message.chat.id, 'Введите выражение типа 9+7:') elif message.text != 'Погода' and message.text != 'Калькулятор' and previous == 'Калькулятор': bot.send_message(message.chat.id, str(eval(message.text)), reply_markup=keyboard()) elif message.text == 'Екатеринбург': bot.send_message(message.chat.id, temp.temp(message.text), reply_markup=keyboard()) elif message.text == 'Москва': bot.send_message(message.chat.id, temp.temp(message.text), reply_markup=keyboard()) else: bot.send_message(message.chat.id, 'Такой команды не существует', reply_markup=keyboard()) previous = message.text
def get_current(): api = { 'time': { 'unix': time.time(), 'date': datetime.datetime.fromtimestamp(time.time()).strftime('%d/%m/%Y'), 'time': datetime.datetime.fromtimestamp(time.time()).strftime('%H:%M') }, 'ht': { 'temp': '{0:.1f}'.format(temp.temp()), 'humidity': round(temp.hmd()) }, } return api
def logCurrent(doc_path='csvlog.csv', human_time=strftime(TIME_FORMAT,localtime()), unix_time=time(), temp=temp.temp(), humidity=temp.hmd()): if DELETE_OLD_LOGS: newSheet = return_cleaned_sheet(RETENTION_TIME) with open(doc_path, 'w') as csvFile: sheet = csv.writer(csvFile, delimiter=',') sheet.writerow(HEADERS) for row in newSheet: sheet.writerow(row) with open(doc_path, 'a') as csvFile: write_headers_if_needed(doc_path) if last_row_unix_time(doc_path) != float(unix_time): sheet = csv.writer(csvFile, delimiter=',') sheet.writerow([human_time, unix_time, temp, humidity])
def SL(): return render_template('Ciudad.html', datos=temp.temp(temp.linkscrap(12)))
def JEE(): return render_template('Ciudad.html', datos=temp.temp(temp.linkscrap(7)))
def Caag(): return render_template('Ciudad.html', datos=temp.temp(temp.linkscrap(6)))
def PJC(): return render_template('Ciudad.html', datos=temp.temp(temp.linkscrap(5)))
def Enc(): return render_template('Ciudad.html', datos=temp.temp(temp.linkscrap(4)))
for i in range(steps): # Forward euler h_ice[i, :, :] = V[i, :, :] # if V > 0.5 -> h_ice = V and h_ice = 1 putmask = V[i, :, :] <= 0.5 h_ice[i, :, :] = ~putmask * h_ice[i, :, :] + putmask * (V[i, :, :]**0.5 / 2.0) x_ice[i, :, :] = ~putmask * x_ice[i, :, :] + putmask * (2 * h_ice[i, :, :]) if i % dt_temp == 0: p[i, :, :, :] = dens(S[i, :, :, :], T[i, :, :, :], pres[:]) # [kg/m] (3d [kg/m^3]) c_w[i, :, :, :] = heatcap(S[i, :, :, :], T[i, :, :, :], pres[:]) # [J/(kg*C)] m[i, :, :, :] = hight[:] * p[i, :, :, :] # [kg] [dT, dV] = temp(T[i, :, :, :], p[i, :, :, :], h, m[i, :, :, :], c_w[i, :, :, :], x_ice[i, :, :], 0 if i < (0.5 * year / dt) else 1, h_ice[i, :, :], I_export) T[i + 1:i + 1 + dt_temp, :, :, :] = T[i, :, :, :] + dt * dT[:, :, :] V[i + 1:i + 1 + dt_temp, :, :] = V[i, :, :] + dt * dV[:, :] S[i + 1:i + 1 + dt_temp, :, :, :] = salt(S[i, :, :, :], p[i, :, :, :], h, x_ice[ i, :, :], I_export, dV / dt) * dt + S[i, :, :, :] else: p[i, :, :, 0] = dens(S[i, :, :, 0], T[i, :, :, 0], pres[0]) p[i, :, :, 1] = dens(S[i, :, :, 1], T[i, :, :, 1], pres[1]) c_w[i, :, :, 0] = heatcap(S[i, :, :, 0], T[i, :, :, 0], pres[0]) # [J/(kg*C)] c_w[i, :, :, 1] = heatcap(S[i, :, :, 1], T[i, :, :, 1], pres[1]) # [J/(kg*C)]
import temp import humi import json import urllib.request import boto3 def UploadCloudWatch(metric, value): cloudwatch = boto3.client('cloudwatch', region_name='eu-west-1') response = cloudwatch.put_metric_data(MetricData=[{ 'MetricName': metric, 'Value': value }], Namespace='Weather') # Uploading local temperature value UploadCloudWatch("TemperatureIn", temp.temp("c")) # Uploading local humidity value UploadCloudWatch("HumidityIn", humi.humidityIn())
import re from temp import temp #maps an id to a name #nodeIDs = {1:'my room temp', 2:'kitchen', 3:'water', 4:'parents room'} #maps and id to a field number field = {1:1, 2:2, 3:4, 4:3} #print "Time, Tom's Room, Kitchen, Parent's Room, Water" for line in open("./sensordata"): line = dict(entry.split('=') for entry in line.split(', ')) try: print "{}{}{:.0f}".format( line['time'][:-1], field[int(line['id'])] * ',', temp(int(line['temp'])) ) except: pass
print("ring") pass def loop(): while True: schedule.run_pending() lcd.update(tmp) if GPIO.input(12) == GPIO.LOW: print("next") music.next_song() time.sleep(1) if __name__ == '__main__': lcd = lcd() tmp = temp() lamp = Lamp() lcd.update(tmp) sleep(5) music = Music() music.load_random() music.play_random() lamp.switch_on() lcd.wake_up(tmp) buttonPin = 12 # define the buttonPin GPIO.setmode(GPIO.BOARD) GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) t = Thread(target=loop) t.start()