4 ms·
Just for fun. What is the shortest micropython server for ON/OFF-type socket? Have not tested this yet: import network,socket,time sta_if = network.WL
by timonoko 2y ago
Just for fun. What is the shortest micropython server for ON/OFF-type socket? Have not tested this yet:
import network,socket,time
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
sta_if.active(True)
sta_if.connect('wifi', 'password')
while not sta_if.isconnected(): pass
from machine import Pin
relayON =Pin(5, Pin.OUT)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 80))
s.listen(5)
while True:
s.settimeout(0.5)
try:
conn, addr = s.accept()
request = conn.recv(1024)
request = str(request)
if request.find('/ON') == 6:
relayON.value(1)
if request.find('/OFF') == 6:
relayON.value(0)
conn.close()
except: pass
- te0006 2y agoIs there a Tasmota version now that includes a MicroPython interpreter?
- timonoko 2y agoThe point is that you don't much need these readymade Tasmotas and whatevers. :-)
- te0006 2y agoI tried micropython, liked it, and developed and operated a few home automation devices with it. But changing anything after a few months was a pain - what flashing tool did I use, how did that detail work, etc. Now I run around 15 Tasmota devices in my household and would never look back. The initial flash, depending on the device at hand, can be trivial (e.g. using https://github.com/tasmota/tasmotizer https://github.com/tasmota/tasmotizer on a device with builtin USB connectivity or with a USB-serial cable) or a bit less so (like the somewhat involved OTA reflashing process https://github.com/yaourdt/mgos-to- https://github.com/yaourdt/mgos-to- for the very handy and inexpensive Shelly devices). In any case, after that it all becomes easy, with web-based configuration, OTA updates, "fleet managament" software like https://github.com/danmed/TasmoBackup https://github.com/danmed/TasmoBackup, and plug&play integratiom with Home Assistant. If somebody integrated micropython into Tasmota for cases where the countless configuration options and libraries integrated into Tasmota don't suffice, it would be perfect. But meanwhile there is a similar scripting language available within Tasmota for ESP32 devices so I can live with that.