Sonoff Devices
Sonoff has created numerous Wifi controllable relays / lights etc. They all use a computer chip that can be flashed that enables MQTT communication via a local WiFi MQTT broker. myServer6 has MQTT broker support built in. So, this is a very economical way to control low volt or line level devices with some DIY skills. The software that enables MQTT on the devices is called "Tasmota". The DIY effort is getting the new software on the Sonoff devices.
Device type should be "Lighting".
Preparing the Sonoff hardware for flashing
Firmware Flash
https://tasmota.github.io/docs/Getting-Started/
Install python to your computer:
https://www.python.org/downloads/
Download Tasmota:
github.com/arendst/Sonoff-Tasmota (download sonoff.bin)
Install ESPTool:
ESPTool is software to flash the ESP8266 chip on the Sonoff:
https://github.com/espressif/esptool
From a Windows command prompt:
cd \Users\"my Stuff"\AppData\Local\Programs\Python\Python38-32\Scripts (use the path where you installed Python)
.\pip install esptool
cd Python23\scripts
Here is how to flash:
Flashing the Sonoff device with Tasmoto
https://tasmota.github.io/docs/devices/Sonoff-4CH-Pro/
For Linux:
from command line:
ls -l /dev/tty.usmodem*
note the usbmodem of your device ie: usbmodem142101
esptool.py -p /dev/tty.usbmodem142101 read_flash 0 0x100000 sonoff-origin.bin
should download a 1mb file to the same directory that esptool is in.
esptool.py -p /dev/tty.usbmodem142101 write_flash -fs 1MB -fm dout 0x0 tasmota_8_1_0.bin
For Windows:
To backup:
Plug in the usb to serial adapter, go into Device Manager and find which com port it attached to (Com8 in this example).
.\esptool.py -p com8 read_flash 0 0x100000 sonoff-origin.bin
To write:
.\esptool.py -p com8 write_flash -fs 1MB -fm dout 0x0 tasmota_8_1_0.bin
Put Sonoff into flash mode. Wait till it boots...Hit Enter to begin flash. Should take 30 seconds or so to flash.
Reboot Sonoff. Connect your PC to the new wiFi device that appears. Note the device name. The last four is the last four of the MAC address.
Configure Sonoff wiFi device settings for your home's wiFi network SSID / password. Click Save.
The Sonoff device will now reboot and connect to your home's wiFi.
.
Control the Sonoff devices on the Network
Once the Sonoff device is on the network accesible to myServer6,
here is the command
mosquitto -h 192.168.0.0 -t "server/command" -m "lighting|1~on"
myServer6 natively supports MQTT. The Tasmota driver translates the return MQTT message from the Sonoff device to update a myServer variable ith the device status (on / off).
Here is the master list of what commands Tasmota supports: