Skip to content

Commit b21a330

Browse files
committed
new file: README.md
new file: src/_C001_DomoHTTP.py new file: src/_C002_DomoMQTT.py new file: src/_C013_ESPEasyP2P.py new file: src/_C014_GenMQTT.py new file: src/_C020_LoraDirect.py new file: src/_N001_Email.py new file: src/_N006_Telegram.py new file: src/_N008_MSTeams.py new file: src/_P001_Switch.py new file: src/_P002_Analog.py new file: src/_P004_Dallas.py new file: src/_P005_DHT.py new file: src/_P010_BH1750.py new file: src/_P014_SI7021.py new file: src/_P023_OLED.py new file: src/_P026_Sysinfo.py new file: src/_P028_BMx280.py new file: src/_P029_DomoOutput.py new file: src/_P033_Dummy.py new file: src/_P038_NeoPixel.py new file: src/_P059_Rotary.py new file: src/_P089_Ping.py new file: src/_P097_ESP32Touch.py new file: src/_P212_Dash.py new file: src/_P259_Slider.py new file: src/_P301_AXP192.py new file: src/_P302_ST7735.py new file: src/_P512_BLEMijia.py new file: src/_P515_BLEMiFlora.py new file: src/_P517_BLELYWSD03.py new file: src/boot.py new file: src/commands.py new file: src/controller.py new file: src/inc/bme280/bme280_float.py new file: src/inc/datacontainer.py new file: src/inc/esp32/axp192/LICENSE new file: src/inc/esp32/axp192/axp192.py new file: src/inc/esp32/lib_axp.py new file: src/inc/esp32/lib_gpiohelper.py new file: src/inc/esp32/lib_part.py new file: src/inc/esp32/lib_plat.py new file: src/inc/esp32/unet.py new file: src/inc/fake/fakemachine.py new file: src/inc/fake/faketime.py new file: src/inc/fake/lib_gpiohelper.py new file: src/inc/fake/lib_plat.py new file: src/inc/fake/unet.py new file: src/inc/helper_domoticz.py new file: src/inc/initdata.py new file: src/inc/lib_blehelper.py new file: src/inc/lib_blescan.py new file: src/inc/lib_gpiohelper.py new file: src/inc/lib_miflora.py new file: src/inc/lib_p2pbuffer.py new file: src/inc/lib_plat.py new file: src/inc/libhw.py new file: src/inc/lora/LICENSE new file: src/inc/lora/sx127x.py new file: src/inc/machine.py new file: src/inc/misc.py new file: src/inc/mrtc.py new file: src/inc/rp2/lib_gpiohelper.py new file: src/inc/rp2/lib_plat.py new file: src/inc/rp2/unet.py new file: src/inc/ssd1306.py new file: src/inc/st7735.py new file: src/inc/suntime/LICENSE new file: src/inc/suntime/Suntime.py new file: src/inc/tinydns/LICENSE new file: src/inc/tinydns/dns.py new file: src/inc/uMail/LICENSE new file: src/inc/uMail/README.md new file: src/inc/uMail/umail.py new file: src/inc/uRTC/LICENSE new file: src/inc/uRTC/urtc.py new file: src/inc/ubtle.py new file: src/inc/umqtt/LICENSE new file: src/inc/umqtt/simple.py new file: src/inc/unet.py new file: src/inc/uping.py new file: src/inc/upyTime.py new file: src/inc/upyrtttl/LICENSE new file: src/inc/upyrtttl/rtttl.py new file: src/inc/utime.py new file: src/inc/writer/LICENSE new file: src/inc/writer/WRITER.md new file: src/inc/writer/courier20.py new file: src/inc/writer/font14.py new file: src/inc/writer/font17.py new file: src/inc/writer/ufont10.py new file: src/inc/writer/ufont12.py new file: src/inc/writer/ufont16.py new file: src/inc/writer/ufont21.py new file: src/inc/writer/ufont31.py new file: src/inc/writer/ufont8.py new file: src/inc/writer/ufont9.py new file: src/inc/writer/writer.py new file: src/mpyeasy.py new file: src/nplugin.py new file: src/pglobals.py new file: src/plugin.py new file: src/settings.py new file: src/urequests.py new file: src/web.py new file: src/webserver.py new file: src/webserver_adv.py new file: src/webserver_blescan.py new file: src/webserver_command.py new file: src/webserver_config.py new file: src/webserver_contr.py new file: src/webserver_csv.py new file: src/webserver_dash.py new file: src/webserver_dev.py new file: src/webserver_devlist.py new file: src/webserver_global.py new file: src/webserver_hw.py new file: src/webserver_i2cscan.py new file: src/webserver_json.py new file: src/webserver_log.py new file: src/webserver_notif.py new file: src/webserver_ota.py new file: src/webserver_root.py new file: src/webserver_rules.py new file: src/webserver_sysinfo.py new file: src/webserver_sysvars.py new file: src/webserver_tools.py new file: src/webserver_wifiscan.py
1 parent 9855025 commit b21a330

File tree

128 files changed

+22758
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+22758
-0
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[![Release downloads](https://img.shields.io/github/downloads/enesbcs/mpyeasy-async/total.svg)]() [![Code size](https://img.shields.io/github/languages/code-size/enesbcs/mpyeasy-async)]() [![Last commit](https://img.shields.io/github/last-commit/enesbcs/mpyeasy-async)]()
2+
3+
# To support the development you can:
4+
- Be a patron at [Patreon](https://www.patreon.com/enesbcs)
5+
- Buy a [coffee](https://ko-fi.com/I3I5UT4H)
6+
- Donate by [PayPal](https://www.paypal.me/rpieasy)
7+
- Adding Python code by [Pull Request](https://github.com/enesbcs/mpyeasy-async/pulls)
8+
9+
# mPyEasy-Async
10+
11+
microPythonEasy IoT firmware for [W5100S-EVB-Pico](https://www.wiznet.io/product-item/w5100s-evb-pico/), [Pico-W](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html#raspberry-pi-pico-w), ESP32-WROOM and ESP32-WROVER (with SPIRAM)
12+
13+
Based on MicroPython this project tries to mimic the magnificent [ESPEasy](https://www.letscontrolit.com/wiki/index.php/ESPEasy) project functions. Python code is heavily based on RPIEasy, partially rewritten from mPyEasy dropping threading and implementing AsyncIO with a very basic Web framework with minimal memory footprint.
14+
Main goal is to create a multisensor device, that can be install and setup quickly.
15+
16+
:warning:THIS IS A BETA TEST VERSION!:warning:
17+
18+
Expect major changes in later versions that may cause incompatibility with earlier versions!
19+
20+
# ESP32 Installation
21+
22+
1/ Recommended method to write the firmware binary to the flash directly. It will run on either WROOM or WROVER variants.
23+
24+
Download image from: https://github.com/enesbcs/mpyeasy-async/releases/
25+
26+
- Erase flash at first time on ESP32:
27+
28+
`esptool.py --port /dev/ttyUSB0 erase_flash`
29+
- Write firmware:
30+
31+
`esptool.py --port /dev/ttyUSB0 write_flash -z 0x1000 firmware.bin`
32+
33+
Or you can simply use [Thonny](https://thonny.org/) to install firmware!
34+
35+
2/ MicroPython source code from the src directory can be copied to the flash onto a WROVER module with 4MB PSRAM!
36+
Without PSRAM it may run out of memory, i warned you!
37+
38+
https://github.com/enesbcs/mpyeasy-async/tree/main/src
39+
40+
# RP2 (Pico) Installation
41+
42+
- Download image from: https://github.com/enesbcs/mpyeasy-async/releases/
43+
- Press the Bootsel button on Pico when connecting to USB, it will open a new Drive.
44+
- Copy the .uf2 image to this drive (suitable for your device)
45+
46+
# Setup (WiFi modells)
47+
48+
- Connect to mpyEasy WIFI AP with configesp password.
49+
- Setup your own wifi data at http://192.168.4.1/config
50+
- Search it on your own network and configure at the obtained dhcp IP with a web browser.
51+
52+
# Setup (LAN modells)
53+
54+
- Connect to a router with LAN cable, it will request a DHCP address
55+
- Search it on your own network and configure at the obtained dhcp IP with a web browser.
56+
57+
# Update
58+
59+
OTA is not supported yet on ESP32, and never will be on RP2
60+
61+
# Compiling
62+
63+
To create firmware image from python sources, follow instructions for compiling standard MicroPython and add mPyEasy source to micropython/ports/esp32/modules subdirectory before "make" command.
64+
65+
https://github.com/micropython/micropython/tree/master/ports/esp32
66+
67+
https://blog.horan.hk/micropythonesp32.html

src/_C001_DomoHTTP.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import controller
2+
import pglobals
3+
from inc.helper_domoticz import *
4+
import inc.misc as misc
5+
try:
6+
import ubinascii as binascii
7+
except ImportError:
8+
import binascii
9+
try:
10+
import urequests
11+
fake = False
12+
except:
13+
import urllib.request as urequests
14+
fake = True
15+
16+
class Controller(controller.ControllerProto):
17+
CONTROLLER_ID = 1
18+
CONTROLLER_NAME = "Domoticz HTTP"
19+
20+
def __init__(self,controllerindex):
21+
controller.ControllerProto.__init__(self,controllerindex)
22+
self.usesID = True
23+
self.usesAccount = True
24+
self.usesPassword = True
25+
26+
def senddata(self,idx,taskobj,changedvalue=-1):
27+
if self.enabled:
28+
if int(idx) != 0:
29+
if int(taskobj.vtype)==pglobals.SENSOR_TYPE_SWITCH:
30+
url = "/json.htm?type=command&param=switchlight&idx="
31+
url += str(idx)
32+
url += "&switchcmd="
33+
if round(float(taskobj.uservar[0])) == 0:
34+
url += "Off"
35+
else:
36+
url += "On"
37+
elif int(taskobj.vtype)==pglobals.SENSOR_TYPE_DIMMER:
38+
url = "/json.htm?type=command&param=switchlight&idx="
39+
url += str(idx)
40+
url += "&switchcmd="
41+
if float(taskobj.uservar[0]) == 0:
42+
url += "Off"
43+
else:
44+
url += "Set%20Level&level="
45+
url += str(taskobj.uservar[0])
46+
else:
47+
url = "/json.htm?type=command&param=udevice&idx="
48+
url += str(idx)
49+
url += "&nvalue=0&svalue="
50+
url += formatDomoticzSensorType(taskobj.vtype,taskobj.uservar)
51+
url += "&rssi="
52+
url += mapRSSItoDomoticz(taskobj.rssi)
53+
if taskobj.battery != -1 and taskobj.battery != 255: # battery input 0..100%, 255 means not supported
54+
url += "&battery="
55+
url += str(int(taskobj.battery))
56+
else:
57+
bval = misc.get_battery_value()
58+
url += "&battery="
59+
url += str(int(bval))
60+
urlstr = self.controllerip+":"+self.controllerport+url+self.getaccountstr()
61+
misc.addLog(pglobals.LOG_LEVEL_DEBUG,urlstr) # sendviahttp
62+
self.urlget(urlstr)
63+
else:
64+
misc.addLog(pglobals.LOG_LEVEL_ERROR,"MQTT : IDX cannot be zero!")
65+
66+
def urlget(self,url):
67+
global fake
68+
url = "http://"+str(url)
69+
try:
70+
if fake:
71+
content = urequests.urlopen(url,None,1)
72+
else:
73+
content = urequests.get(url)
74+
except Exception as e:
75+
misc.addLog(pglobals.LOG_LEVEL_ERROR,"Controller: "+self.controllerip+" connection failed "+str(e))
76+
77+
def getaccountstr(self):
78+
retstr = ""
79+
if self.controlleruser!="" or self.controllerpassword!="":
80+
acc = binascii.b2a_base64(bytes(self.controlleruser))
81+
pw = binascii.b2a_base64(bytes(self.controllerpassword))
82+
retstr = "&username="+ str(acc) +"&password="+ str(pw)
83+
return retstr

0 commit comments

Comments
 (0)