def main(): # Setup the Rasp.IO LED Strings ledstrip = apa.Apa(led_config.numleds) # initiate an LED strip ledstrip.zero_leds() ledstrip.write_leds() clock = ClockRing(ledstrip) clock.start() # Set up the handler class handlerclass = Temperature(ledstrip) # Start MQTT Listener Messages.MQTTMessages(config.mqttconfig, handlerclass) handlerclass.start() pause()
@app.route('/getTempStr') def get_temp_html(): cond = get_temperature() cond_avg = t.get_today_avg() cond_max = t.get_today_max() ret = f"Temp: {get_temp_str(cond[0])} <br/>" + f"Humidity: {cond[1]:.0f}% <br/>" ret += f"Temp Avg: {get_temp_str(cond_avg[0])} <br/>" + f"Humidity Avg: {cond_avg[1]:.0f}% <br/>" ret += f"Temp Max: {get_temp_str(cond_max[0])} <br/>" + f"Temp Min: {get_temp_str(cond_max[1])}" return ret, 200 @app.route('/favicon.ico') def favicon(): return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', mimetype='image/vnd.microsoft.icon') if __name__ == '__main__': host_name = socket.gethostbyname(socket.gethostname()) try: stream = os.popen('hostname -I') host_name = stream.read().strip() except all: host_name = ip logger.info("machine host_name[" + host_name + "]") check() t.start() app.run(host=host_name, port=port)