### Splash Screen Setup Example
Source: https://tasmota.github.io/docs/Universal-Display-Driver
Example of a splash screen setup defining font, colors, and text position.
```APIDOC
:S,2,1,1,0,40,20
```
--------------------------------
### Initial Register Setup Example (SPI)
Source: https://tasmota.github.io/docs/Universal-Display-Driver
Example of initial register setup commands for a display controller, formatted for SPI communication.
```APIDOC
:I
EF,3,03,80,02
CF,3,00,C1,30
ED,4,64,03,12,81
E8,3,85,00,78
CB,5,39,2C,00,34,02
F7,1,20
EA,2,00,00
C0,1,23
C1,1,10
C5,2,3e,28
C7,1,86
36,1,48
37,1,00
3A,1,55
B1,2,00,18
B6,3,08,82,27
F2,1,00
26,1,01
E0,0F,0F,31,2B,0C,0E,08,4E,F1,37,07,10,03,0E,09,00
E1,0F,00,0E,14,03,11,07,31,C1,48,08,0F,0C,31,36,0F
11,80
29,80
```
--------------------------------
### Tasmota Scripting Cookbook Example
Source: https://tasmota.github.io/docs/Scripting-Language
An example Tasmota script demonstrating webcam control and display. It initializes the camera, captures resolution, starts a motion detector, and displays motion difference and brightness values along with the live stream in the WEBUI.
```Tasmota Script
>D
res=0
w=0
h=0
mot=0
bri=0
>B
; init cam with QVGA
res=wc(0 4)
; get pixel size
w=wc(3)
h=wc(4)
; start motion detector, picture every 1000 ms
mot=wc(6 1000)
>S
if wific>0
then
; when wifi up, start stream
res=wc(5 1)
endif
; get motion detect diff value
mot=wc(6 -1)
; get picture brightnes
bri=wc(6 -2)
>W
motion diff = %mot%
brightness = %bri%
; show stream on WEBUI
&
&
&
webcam stream
```
--------------------------------
### BLE Server Example (Berry)
Source: https://tasmota.github.io/docs/Bluetooth_MI32
Illustrates the setup for a BLE server using the Tasmota Berry console. It shows how to initiate the server role, define a callback, and prepare for adding characteristics and advertisement data. This is for devices acting as BLE peripherals.
```berry
# simple server setup example for the Berry console
import BLE
cbuf = bytes(-256)
def cb(error,op,uuid,handle)
end
cbp = tasmota.gen_cb(cb)
BLE.serv_cb(cbp,cbuf)
# now add characteristics and advertisement ...
```
--------------------------------
### Berry Example: Registering Virtual Lights
Source: https://tasmota.github.io/docs/Berry
Example Berry code demonstrating how to import the `hue_bridge` module and register virtual lights using the `light_state` class. This setup is typically placed in `autoexec.be` to ensure lights are available on startup.
```Berry
# put this in `autoexec.be`
import hue_bridge
l1 = light_state(light_state.DIMMER)
hue_bridge.add_light(11, l1, "Synthetic Dimmer", "V1", "Tasmota Factory")
l2 = light_state(light_state.CT)
hue_bridge.add_light(12, l2, "Synthetic CT", "V1", "Tasmota Factory")
l5 = light_state(light_state.RGBCT)
hue_bridge.add_light(15, l5, "Synthetic RGBCT")
```
--------------------------------
### Tasmota tcpclient Usage Example
Source: https://tasmota.github.io/docs/Berry
A full example demonstrating how to use the Tasmota tcpclient to connect to a server, send an HTTP GET request, and read the response.
```Lua
tcp = tcpclient()
tcp.connect("192.168.2.204", 80)
print("connected:", tcp.connected())
s= "GET / HTTP/1.0\r\n\r\n"
tcp.write(s)
print("available1:", tcp.available())
tasmota.delay(100)
print("available1:", tcp.available())
r = tcp.read()
tcp.close()
print(r)
```
--------------------------------
### Install Esptool
Source: https://tasmota.github.io/docs/Esptool
Installs the esptool.py utility. This can be done via Python's setup script or package managers for Debian/Ubuntu systems.
```python
python setup.py install
```
```bash
sudo apt install esptool
```
--------------------------------
### Install esptool.py
Source: https://tasmota.github.io/docs/Getting-Started
Installs the esptool.py utility, which is required for flashing ESP devices. This command uses pip, the Python package installer.
```shell
pip install esptool
```
--------------------------------
### Tasmota uDisplay/uTouch Migration Steps
Source: https://tasmota.github.io/docs/Universal-Display-Driver
Provides a step-by-step guide for migrating existing Tasmota setups to utilize the Universal Display (uDisplay) and Universal Touch (uTouch) drivers. This includes checking display compatibility, flashing compatible binaries, configuring GPIOs, and setting up the descriptor file.
```APIDOC
Migrating to uDisplay:
Step 1. Check that your display is supported by uDisplay driver
- Verify hardware compatibility with the uDisplay driver.
Step 2. Flash with uDisplay compatible binary
- Use a Tasmota firmware build that includes the uDisplay driver.
Step 3. Use autoconf (ESP32 only)
- Leverage automatic configuration features if available for ESP32.
Step 4. Configure GPIOs
- Assign the correct GPIO pins for display communication (e.g., SPI, I2C).
Step 5. Configure the display.ini descriptor file
- Create or modify the descriptor file to define display parameters.
Step 6. Restart
- Reboot the device for the new configuration to take effect.
Migrating to uTouch:
Step 1. Check you display.ini
- Ensure the existing descriptor file is correctly formatted.
Step 2. Add uTouch section to display.ini
- Include a dedicated section for touch controller configuration.
Step 3. Restart
- Apply changes by restarting the Tasmota device.
```
--------------------------------
### Install esptool.py
Source: https://tasmota.github.io/docs/Create-your-own-Firmware-Build-without-IDE
Installs the esptool.py package, a utility for programming ESP8266 and ESP32 microcontrollers, using pip within an activated virtual environment. Includes dependency installation.
```shell
(esptool) [tasmota_installer@lantash ~/esptool]$ pip install esptool
Collecting esptool
Downloading https://files.pythonhosted.org/packages/5c/85/5654e7b9019739d3d89af0adf528c9ae57a9a26682e3aa012e1e30f20674/esptool-2.6.tar.gz (80kB)
100% |################################| 81kB 222kB/s
Collecting pyserial>=3.0 (from esptool)
Downloading https://files.pythonhosted.org/packages/0d/e4/2a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30/pyserial-3.4-py2.py3-none-any.whl (193kB)
100% |################################| 194kB 491kB/s
Collecting pyaes (from esptool)
Downloading https://files.pythonhosted.org/packages/44/66/2c17bae31c906613795711fc78045c285048168919ace2220daa372c7d72/pyaes-1.6.1.tar.gz
Collecting ecdsa (from esptool)
Downloading https://files.pythonhosted.org/packages/63/f4/73669d51825516ce8c43b816c0a6b64cd6eb71d08b99820c00792cb42222/ecdsa-0.13-py2.py3-none-any.whl (86kB)
100% |################################| 92kB 382kB/s
Building wheels for collected packages: esptool, pyaes
Running setup.py bdist_wheel for esptool ... done
Stored in directory: /home/tasmota_installer/.cache/pip/wheels/cf/1f/62/7ad4e47843affd4f5b7032a39f1ef8a153c6d27533614d21aa
Running setup.py bdist_wheel for pyaes ... done
Stored in directory: /home/tasmota_installer/.cache/pip/wheels/bd/cf/7b/ced9e8f28c50ed666728e8ab178ffedeb9d06f6a10f85d6432
Successfully built esptool pyaes
Installing collected packages: pyserial, pyaes, ecdsa, esptool
Successfully installed ecdsa-0.13 esptool-2.6 pyaes-1.6.1 pyserial-3.4
```
--------------------------------
### Wi-Fi Sniffing Setup (Linux)
Source: https://tasmota.github.io/docs/FAQ
Installs and starts Wi-Fi sniffing tools like aircrack-ng and wireshark on a Linux system. This helps in identifying misconfigured SSIDs by monitoring network traffic.
```shell
apt install aircrack-ng wireshark
airmon-ng check kill
airmon-ng start (e.g. wlp58s0 or wlan0)
wireshark
```
--------------------------------
### Tasmota Configuration - Initial Setup
Source: https://tasmota.github.io/docs/TuyaMCU-Devices
Steps to configure Tasmota after flashing, including connecting to the Tasmota Wi-Fi network, accessing the web interface, and saving network credentials.
```APIDOC
Post-Flashing Configuration:
1. Disconnect GND from GPIO0 (and RST if applicable).
2. Power the device via USB.
3. Connect to the Wi-Fi network named 'sonoff-xxxx'.
4. Access the web interface at 192.168.4.1.
5. Enter your Wi-Fi credentials and save.
6. Reconnect your PC to your network and find the Tasmota device's IP address.
```
--------------------------------
### LVGL Initialization and UI Setup in Berry
Source: https://tasmota.github.io/docs/LVGL
This script initializes the LVGL graphics library, sets up the screen with a gradient background, adds a status line with icons, and creates interactive buttons with event callbacks. It demonstrates basic LVGL widget creation and event handling in the Tasmota environment.
```Berry
#- start LVGL and init environment -#
lv.start()
hres = lv.get_hor_res() # should be 320
vres = lv.get_ver_res() # should be 240
scr = lv.scr_act() # default screen object
f20 = lv.montserrat_font(20) # load embedded Montserrat 20
#- Background with a gradient from black #000000 (bottom) to dark blue #0000A0 (top) -#
scr.set_style_bg_color(lv.color(0x000077), lv.PART_MAIN | lv.STATE_DEFAULT)
#- Upper state line -#
stat_line = lv.label(scr)
if f20 != nil stat_line.set_style_text_font(f20, lv.PART_MAIN | lv.STATE_DEFAULT) end
stat_line.set_long_mode(lv.LABEL_LONG_SCROLL) # auto scrolling if text does not fit
stat_line.set_width(hres)
stat_line.set_align(lv.TEXT_ALIGN_LEFT) # align text left
stat_line.set_style_bg_color(lv.color(0xD00000), lv.PART_MAIN | lv.STATE_DEFAULT) # background #000088
stat_line.set_style_bg_opa(lv.OPA_COVER, lv.PART_MAIN | lv.STATE_DEFAULT) # 100% background opacity
stat_line.set_style_text_color(lv.color(0xFFFFFF), lv.PART_MAIN | lv.STATE_DEFAULT) # text color #FFFFFF
stat_line.set_text("Tasmota")
stat_line.refr_size() # new in LVGL8
stat_line.refr_pos() # new in LVGL8
#- display wifi strength indicator icon (for professionals ;) -#
wifi_icon = lv_wifi_arcs_icon(stat_line) # the widget takes care of positioning and driver stuff
clock_icon = lv_clock_icon(stat_line)
#- create a style for the buttons -#
btn_style = lv.style()
btn_style.set_radius(10) # radius of rounded corners
btn_style.set_bg_opa(lv.OPA_COVER) # 100% background opacity
if f20 != nil btn_style.set_text_font(f20) end # set font to Montserrat 20
btn_style.set_bg_color(lv.color(0x1fa3ec)) # background color #1FA3EC (Tasmota Blue)
btn_style.set_border_color(lv.color(0x0000FF)) # border color #0000FF
btn_style.set_text_color(lv.color(0xFFFFFF)) # text color white #FFFFFF
#- create buttons -#
prev_btn = lv.btn(scr) # create button with main screen as parent
prev_btn.set_pos(20,vres-40) # position of button
prev_btn.set_size(80, 35) # size of button
prev_btn.add_style(btn_style, lv.PART_MAIN | lv.STATE_DEFAULT) # style of button
prev_label = lv.label(prev_btn) # create a label as sub-object
prev_label.set_text("< ") # set label text
prev_label.center()
next_btn = lv.btn(scr) # right button
next_btn.set_pos(220,vres-40)
next_btn.set_size(80, 35)
next_btn.add_style(btn_style, lv.PART_MAIN | lv.STATE_DEFAULT)
next_label = lv.label(next_btn)
next_label.set_text("> ")
next_label.center()
home_btn = lv.btn(scr) # center button
home_btn.set_pos(120,vres-40)
home_btn.set_size(80, 35)
home_btn.add_style(btn_style, lv.PART_MAIN | lv.STATE_DEFAULT)
home_label = lv.label(home_btn)
home_label.set_text(lv.SYMBOL_OK) # set text as Home icon
home_label.center()
#- callback function when a button is pressed, react to EVENT_CLICKED event -#
def btn_clicked_cb(obj, event)
var btn = "Unknown"
if obj == prev_btn btn = "Prev"
elif obj == next_btn btn = "Next"
elif obj == home_btn btn = "Home"
end
# get the coordinates
var indev = event.get_indev()
var point = lv.point()
indev.get_point(point)
# get local coordinates
var area = lv.area()
obj.get_coords(area)
print(f"{btn} button pressed at ({point.x},{point.y}) local ({point.x - area.x1},{point.y - area.y1})")
end
prev_btn.add_event_cb(btn_clicked_cb, lv.EVENT_CLICKED, 0)
next_btn.add_event_cb(btn_clicked_cb, lv.EVENT_CLICKED, 0)
home_btn.add_event_cb(btn_clicked_cb, lv.EVENT_CLICKED, 0)
#- Grouping buttons for input device control -#
g = lv.group()
g.add_obj(prev_btn)
g.add_obj(home_btn)
g.add_obj(next_btn)
```
--------------------------------
### Configure ArtNet for LED Matrix (5x5)
Source: https://tasmota.github.io/docs/ArtNet
This command configures Tasmota for an ArtNet DMX LED matrix setup. It specifies the number of rows and columns, offset, whether lines are alternate, and the starting universe. This example is for a 5x5 matrix without alternate lines.
```text
ArtNetConfig {"Rows":5, "Cols":5, "Offset":0, "Alternate":false, "Universe":0}
ArtNet Start
```
--------------------------------
### Configure ArtNet for LED Matrix (8x8 Alternate)
Source: https://tasmota.github.io/docs/ArtNet
This command configures Tasmota for an ArtNet DMX LED matrix setup with alternate lines. It specifies the number of rows and columns, offset, alternate line setting, and the starting universe. This example is for an 8x8 matrix with alternate lines.
```text
ArtNetConfig {"Rows":8, "Cols":8, "Offset":0, "Alternate":true, "Universe":0}
ArtNet Start
```
--------------------------------
### Tasmota Driver Example: Adding Buttons
Source: https://tasmota.github.io/docs/Berry-Cookbook
An example Berry script demonstrating how to add buttons to the Tasmota main and configuration menus and handle their associated actions using the webserver class.
```berry
import webserver # import webserver class
class MyButtonMethods
def myOtherFunction(myValue)
#- do something -#
print("myOtherFunction called with: " + str(myValue))
end
#- create a method for adding a button to the main menu -#
def web_add_main_button()
webserver.content_send("")
end
#- create a method for adding a button to the configuration menu-#
def web_add_config_button()
#- the onclick function "la" takes the function name and the respective value you want to send as an argument -#
webserver.content_send("")
end
#- As we can add only one sensor method we will have to combine them besides all other sensor readings in one method -#
def web_sensor()
if webserver.has_arg("m_toggle_main")
print("Toggle Main button pressed")
end
if webserver.has_arg("m_toggle_conf") # takes a string as argument name and returns a boolean
# we can even call another function and use the value as a parameter
var myValue = int(webserver.arg("m_toggle_conf")) # takes a string or integer(index of arguments) to get the value of the argument
self.myOtherFunction(myValue)
end
end
end
d1 = MyButtonMethods()
tasmota.add_driver(d1)
```
--------------------------------
### Berry Identifier Examples
Source: https://tasmota.github.io/docs/_media/BERRY_LANGUAGE_REFERENCE
Provides examples of valid identifiers in Berry, which are names for variables, functions, and classes. Berry identifiers are case-sensitive and start with an underscore or letter.
```berry
a
TestVariable
Test_Var
_init
baseClass
_
```
--------------------------------
### BLE Client Example (Berry)
Source: https://tasmota.github.io/docs/Bluetooth_MI32
Demonstrates setting up a BLE client to connect to a device, register a callback for received data, and initiate operations like reading or subscribing. It shows the basic structure for BLE communication from the Tasmota device.
```berry
import BLE
cbuf = bytes(-64)
def cb(error,op,uuid,handle)
end
cbp = tasmota.gen_cb(/e,o,u,h->cb)
BLE.conn_cb(cbp,cbuf)
```
--------------------------------
### NeoPool Settings Persistence and Rules Example
Source: https://tasmota.github.io/docs/NeoPool
Explanation of how NeoPool settings are stored and an example rule for setting defaults during system initialization.
```APIDOC
Note on Settings Persistence:
- Settings changed by NPPHRes, NPCLRes, NPIONRes, NPSetOption0, and NPSetOption1 are permanently stored only if firmware was compiled with USE_UFILESYS (default enabled on ESP32, disabled on ESP82xx).
- Without USE_UFILESYS (default on ESP82xx), use a rule to set defaults during system start.
Example Rule for Defaults:
Rule1 ON System#Init DO Backlog NPPHRes 1;NPCLRes 1;NPIonRes 1;NPSetOption0 1;NPSetOption1 0
See also:
- [SetOption157](../Commands/#setoption157) - Hide/Show sensitive data
```
--------------------------------
### Linux Installation for TasmoAdmin
Source: https://tasmota.github.io/docs/TasmoAdmin
Details the installation process for TasmoAdmin on Linux/Unix hosts. Requires a web server (e.g., apache2), PHP7 with specific modules (php-curl, php-zip), and enabled mod_rewrite. Users are advised to consult OS-specific guides.
```Linux
Running TasmoAdmin on a Linux/Unix hosts requires the following:
A Webserver
apache2 recommended
php7 recommended (works with php5 too)
php-curl php-zip Modules installed
You need to install a web server with php-zip and php-curl modules installed. Also mod_rewrite must be enabled.
I suggest to look in the Guide for Ubuntu Server 16.04 and try to adjust it to your server OS.
```
--------------------------------
### Create and Use a 'Greeter' Object in Berry
Source: https://tasmota.github.io/docs/Berry-Introduction
Shows how to instantiate the 'Greeter' class, call its methods, and access its instance variables. It demonstrates object creation and method invocation.
```Berry
> greeter = Greeter("Pat")
> greeter.say_hi()
Hi Pat
> greeter.say_bye()
Bye Pat, come back soon.
> greeter.name
Pat
```
--------------------------------
### tuya-convert Flashing Script Commands
Source: https://tasmota.github.io/docs/devices/RGB-Smart-Plug-16A
This section outlines the primary shell commands used to initiate and manage the tuya-convert flashing process. It includes running the prerequisite installation script, starting the main flashing script, and stopping the flashing script after successful firmware installation.
```shell
install_prereq.sh
```
```shell
start_flash.sh
```
```shell
stop_flash.sh
```
--------------------------------
### Basic Shutter MQTT Integration Example
Source: https://tasmota.github.io/docs/Home-Assistant
An alternative integration example for shutters, focusing on basic state and command topics. This configuration uses a value template to interpret the state and defines payloads for open, close, and stop actions.
```yaml
mqtt:
cover:
- name: "Test"
availability_topic: "tele/%topic%/LWT"
state_topic: "stat/%topic%/RESULT"
command_topic: "cmnd/%topic%/Backlog"
value_template: '{{ value | int }}'
qos: 1
retain: false
payload_open: "ShutterOpen1"
payload_close: "ShutterClose1"
payload_stop: "ShutterStop1"
state_open: "ON"
state_closed: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
optimistic: false
tilt_command_topic: 'cmnd/%topic%/ShutterPosition1'
tilt_status_topic: 'cmnd/%topic%/ShutterPosition1'
set_position_topic: 'cmnd/%topic%/ShutterPosition1'
position_topic: "stat/%topic%/SHUTTER1"
tilt_min: 0
tilt_max: 100
tilt_closed_value: 0
tilt_opened_value: 100
```
--------------------------------
### Tasmota Module and Relay Configuration Example
Source: https://tasmota.github.io/docs/NeoPool
Illustrates the structure of module installation and relay assignment configuration. Module availability (pH, Redox, etc.) requires the module to be installed and activated (value 1). Relay assignments specify which physical relay is linked to a function.
```JSON
{
"Modules": {
"pH": 1,
"Redox": 1,
"Hydrolysis": 1,
"Chlorine": 0,
"Conductivity": 0,
"Ionization": 0
},
"Relay": {
"Acid": 1,
"Base": 0,
"Redox": 0,
"Chlorine": 0,
"Conductivity": 0,
"Heating": 4,
"UV": 0,
"Valve": 0
}
}
```
--------------------------------
### Webserial ESPTool for Firmware Installation
Source: https://tasmota.github.io/docs/Gitpod
Instructions for installing custom Tasmota firmware using the Webserial ESPTool, which allows flashing directly from a web browser. It specifies downloading a factory binary and flashing it from offset 0x0.
```markdown
Install your custom firmware with a web browser using [Webserial ESPTool](https://jason2866.github.io/WebSerial_ESPTool/).
Download the `tasmota-xxx.factory.bin` and flash it from offset 0x0.
```
--------------------------------
### Initialize animate.core
Source: https://tasmota.github.io/docs/Berry_Addressable-LED
Demonstrates the basic setup for the `animate.core` class, requiring a `Leds` object representing the LED strip and its configuration.
```berry
import animate
var strip = Leds(25, gpio.pin(gpio.WS2812, 0))
var anim = animate.core(strip)
```
--------------------------------
### Tasmota KNX Usage Examples
Source: https://tasmota.github.io/docs/KNX
Demonstrates various ways to configure and use Tasmota devices with KNX for home automation. Includes examples for device linking, scene initiation, sensor data transmission, and rule-based automation.
```APIDOC
Tasmota KNX Integration Examples:
1) Setting Several Tasmota to be controlled as one by a Home Automation System:
- Description: Configure multiple Tasmota devices to act as a single entity within a KNX home automation system.
- Usage: Typically involves setting up consistent group addresses and device naming conventions.
2) Setting 2 Tasmota to be linked as stair lights:
- Description: Link two Tasmota devices to simulate stair lighting behavior, where one device's state affects the other.
- Usage: May involve specific KNX group addresses for communication between the devices or using Tasmota rules.
3) Setting a button as initiator of a scene:
- Description: Use a physical button connected to a Tasmota device to trigger a KNX scene.
- Usage: Map button presses to KNX group write commands that activate specific scenes.
4) Setting a Temperature sensor:
- Description: Transmit temperature readings from a Tasmota-connected sensor (e.g., BH1750) over KNX.
- Usage: Configure Tasmota to read sensor data and send it to a designated KNX group address for temperature reporting.
5) Using rules:
- Description: Leverage Tasmota's rule engine to create custom logic for KNX interactions.
- Usage: Define rules that trigger KNX communication based on device states, sensor values, or time events.
- Example Rule Syntax:
`Rule1 ON Power1#State DO KNXGroupAddress12 1 ENDON`
`Rule2 ON BH1750#Illuminance DO KNXGroupAddress13 %value% ENDON`
6) Rule to send KNX Telegram with BH1750 Sensor Data:
- Description: A specific rule example to send BH1750 illuminance sensor data to a KNX group address.
- Usage: This rule reads the illuminance value and sends it to a predefined KNX group address.
- Example Rule:
`Rule1 ON BH1750#Illuminance DO KNXGroupAddress13 %value% ENDON`
- Parameters:
- `BH1750#Illuminance`: The sensor reading for illuminance.
- `KNXGroupAddress13`: The target KNX group address for sending the data.
- `%value%`: Placeholder for the actual sensor reading.
General KNX Configuration in Tasmota:
- Tasmota requires specific configuration for KNX communication, typically involving setting KNX group addresses and enabling the KNX protocol in the device's configuration settings.
```
--------------------------------
### Initiate OTA Upgrade
Source: https://tasmota.github.io/docs/Upgrading
Starts the Over-The-Air firmware upgrade process on the Tasmota device. The device will attempt to download and install the firmware from the URL set by the OtaUrl command.
```tasmota-cli
Upgrade 1
```
--------------------------------
### OTA Install with Tuya-Convert
Source: https://tasmota.github.io/docs/devices/BlitzWolf-SHP2
This method allows for Over-The-Air installation of Tasmota firmware without requiring any physical wiring. It leverages the tuya-convert tool, which includes a basic Tasmota version but allows for custom firmware selection during the process. Note that older Tasmota versions may lack features like Home Assistant auto-discovery.
```guide
Since SHP2 is one of those Tuya based devices this OTA Tasmota installation method works just fine: https://github.com/ct-Open-Source/tuya-convert
The Tuya-convert has a built in Tasmota v6.5.0 basic(but you can define any firmware during the install), remember, that basic version doesn't come with homeassistant auto discovery support, but Tasmota OTA works as expected.
This method does not need any wiring.
```
--------------------------------
### Prepare Python Virtual Environment
Source: https://tasmota.github.io/docs/Create-your-own-Firmware-Build-without-IDE
Demonstrates creating a Python virtual environment using `virtualenv` and activating it. It also shows how to upgrade the pip package manager within the environment.
```shell
[tasmota_installer@lantash ~]$ virtualenv esptool
New python executable in /home/tasmota_installer/esptool/bin/python2.7
Also creating executable in /home/tasmota_installer/esptool/bin/python
Installing setuptools, pip, wheel...done.
[tasmota_installer@lantash ~]$ cd esptool/
[tasmota_installer@lantash ~/esptool]$ . bin/activate
(esptool) [tasmota_installer@lantash ~/esptool]$ pip install --upgrade pip
Requirement already up-to-date: pip in ./lib/python2.7/site-packages (18.1)
```
--------------------------------
### Tasmota Serial Plotter Usage
Source: https://tasmota.github.io/docs/TouchPin
Command-line example for running the Tasmota serial plotter tool, which helps visualize touch values. This tool requires 'matplotlib' and 'pyserial' to be installed.
```Bash
./serial-plotter.py --port /dev/XXX --baud 115200
```
--------------------------------
### Tasmota Wi-Fi and MQTT Configuration using Backlog
Source: https://tasmota.github.io/docs/Getting-Started
This snippet demonstrates how to configure Wi-Fi credentials, secondary Wi-Fi, MQTT broker details, a unique device topic, and an OTA update URL using the Tasmota Backlog command. The Backlog command allows multiple commands to be executed sequentially, often used to avoid device reboots between configuration steps.
```APIDOC
Tasmota Backlog Commands:
Configure Wi-Fi and MQTT:
Backlog ssid1 ; password1 ; ssid2 ; password2 ; mqtthost ; mqttuser ; mqttpassword ; topic ; otaurl http://ota.tasmota.com/tasmota/release/tasmota.bin
Description:
This command sequence configures essential device settings. It sets the primary and secondary Wi-Fi network credentials, MQTT broker connection details (host, username, password), a unique MQTT topic for the device, and the URL for over-the-air firmware updates.
Parameters:
ssid1: Your primary Wi-Fi network name (SSID).
password1: Your primary Wi-Fi network password.
ssid2: Your secondary Wi-Fi network name (SSID) (optional).
password2: Your secondary Wi-Fi network password (optional).
mqtthost: The hostname or IP address of your MQTT broker.
mqttuser: The username for MQTT authentication.
mqttpassword: The password for MQTT authentication.
topic: A unique topic name for this Tasmota device in your MQTT system.
otaurl: The URL pointing to the Tasmota firmware binary for OTA updates.
Usage:
Copy and paste the entire Backlog command into the serial terminal after connecting to the device. The device will process the commands sequentially. After applying these settings, the device will typically restart and connect to your network.
Related Commands:
- SetOption65: Disables power cycle recovery.
- Commands: Refer to the Tasmota Commands documentation for a full list of available commands.
```
--------------------------------
### Range Iteration Example
Source: https://tasmota.github.io/docs/Berry-Introduction
Shows how to iterate over a numerical range using the `for` loop syntax. The range `0..4` includes both the start and end values, resulting in 5 iterations.
```berry
> for i:0..4 print(i) end
0
1
2
3
4
```
--------------------------------
### Tasmota Meter Configuration Examples
Source: https://tasmota.github.io/docs/Smart-Meter-Interface
Illustrates various meter configurations using the defined syntax for different meter types and settings, including OBIS, SML, Counter, and VBus.
```APIDOC
Example Configurations:
+1,3,o,0,9600,OBIS1,1,2,2F3F210D0A
+1,3,o,0,9600,OBIS1,1(i4),2,2F3F210D0A // with pin 4 as inverted TX enable
+1,3,o,16,115200,NormalTariff,1
+1,3,s,16,9600,SML1
+1,12,c,1,-10,H20_Cnt
+1,3,v,0,9600,Solar
```
--------------------------------
### Example: MCP23S17 Shelly Pro 4PM Configuration
Source: https://tasmota.github.io/docs/MCP230xx
This JSON template configures an MCP23S17 chip, mapping specific GPIOs to functions like switches and relays, as seen in a Shelly Pro 4PM setup.
```json
{"NAME":"MCP23S17 Shelly Pro 4PM","GPIO":[194,193,65,66,3840,64,192,0,224,0,0,0,227,225,226,195]}
```
--------------------------------
### Get Tasmota Sensor Status
Source: https://tasmota.github.io/docs/Matter
Example output from the Tasmota console command `Status 8`, used to retrieve sensor data and identify parameter values for Matter endpoint configuration.
```console
MQT: tele/tasmota/SENSOR = {"Time":"2023-05-28T20:04:27","SCD40":{"CarbonDioxide":618,"eCO2":623,"Temperature":23.8,"Humidity":61.1,"DewPoint":15.8},"TempUnit":"C"}
```
--------------------------------
### uDisplay/uTouch Configuration Examples
Source: https://tasmota.github.io/docs/Universal-Display-Driver
Provides example configurations for different touch controllers within the `display.ini` descriptor file for Tasmota's Universal Touch driver. These examples demonstrate how to define parameters for specific touch hardware.
```APIDOC
uTouch Configuration Examples (display.ini):
FT5206 example:
```ini
[ft5206]
I2CAddress=0x38
```
XPT2046 example:
```ini
[xpt2046]
SPIClock=10000000
SPIFrequency=10000000
SPIDataBits=8
SPIMode=0
SPIDelay=0
SPICS=5
```
GT911 example:
```ini
[gt911]
I2CAddress=0x5d
```
Simple resistive touch example:
```ini
[resistive]
```
```
--------------------------------
### Create and Activate PlatformIO Virtual Environment
Source: https://tasmota.github.io/docs/Create-your-own-Firmware-Build-without-IDE
Demonstrates creating a self-contained Python virtual environment using `virtualenv` and activating it for use with PlatformIO-Core. This ensures isolated dependencies and proper execution context.
```bash
[tasmota_builder@jtest ~]$ virtualenv platformio-core
New python executable in /home/tasmota_builder/platformio-core/bin/python
Installing setuptools, pip, wheel...done.
[tasmota_builder@jtest platformio-core]$ cd platformio-core
[tasmota_builder@jtest platformio-core]$ . bin/activate
(platformio-core) [tasmota_builder@jtest platformio-core]$
```
--------------------------------
### Introspect Module Example
Source: https://tasmota.github.io/docs/Berry
Illustrates how to use the `introspect` module for examining and modifying object attributes programmatically. It shows listing members, getting, and setting attribute values.
```Berry
> class A var a,b def f() return 1 end end
> ins=A()
> ins.a = "foo"
> import introspect
> introspect.members(ins)
['b', 'a', 'f']
> introspect.get(ins, "a")
foo
> introspect.set(ins, "a", "bar")
bar
> ins.a
bar
```
--------------------------------
### Tasmota Command Syntax and Examples
Source: https://tasmota.github.io/docs/Commands
Explains the general structure of Tasmota commands, including how to use parameters, index numbers, and value aliases. It also covers how commands return current settings when used without parameters.
```text
Power
# Returns the status of the first defined power output (usually Relay1)
Power ON
# Turns the first defined power output (usually Relay1) on
Power1 1
# Also turns the first defined power output (usually Relay1) on
Power1 True
# Also turns the first defined power output (usually Relay1) on
# Replace with the appropriate index number. Leave empty for the first available.
Power1
# Controls the first defined power output (usually Relay1)
# Commands with x..y value parameters use a number from x to y range.
# Commands prefixed with _ will not be logged or published via MQTT.
_Power ON
# Turns the first defined power output on, but result is not logged/published.
```
```text
IPAddress1 192.168.1.123
# Sets the device's IP address using the IPAddress command.
```
--------------------------------
### Example: Inverted Relays and Buttons with Offset Configuration
Source: https://tasmota.github.io/docs/MCP230xx
This JSON template configures an MCP23017 with inverted relays and buttons, using a BASE value of 1 to apply an offset to the numbering. It maps pins starting from the second relay/button.
```json
{"NAME":"MCP23017 A=Ri2-10, B=B2-10","BASE":1,"GPIO":[258,259,260,261,262,263,264,265,34,35,36,37,38,39,40,41]}
```
--------------------------------
### Tasmota MQTT Subscription Example
Source: https://tasmota.github.io/docs/openHAB
Demonstrates subscribing to Tasmota device MQTT topics using `mosquitto_sub`. This example shows how to monitor device status, energy readings, and command responses from a Sonoff Pow module using a wildcard topic. Requires the `mosquitto_sub` client.
```Shell
$ mosquitto_sub -h localhost -t "+/tasmota_E8A6E4/#" -v
tele/tasmota-E8A6E4/LWT Online
tele/tasmota-E8A6E4/UPTIME {"Time":"2017-07-25T12:02:00", "Uptime":68}
tele/tasmota-E8A6E4/STATE {"Time":"2017-07-25T12:06:28", "Uptime":68, "Vcc":3.122, "POWER":"POWER", "Wifi":{"AP":1, "SSID":"HotelZurBirke", "RSSI":100, "APMac":"24:65:11:BF:12:D8"}}
tele/tasmota-E8A6E4/ENERGY {"Time":"2017-07-25T12:06:28", "Total":0.640, "Yesterday":0.007, "Today":0.003, "Period":0, "Power":0, "Factor":0.00, "Voltage":0, "Current":0.000}
tele/tasmota-E8A6E4/STATE {"Time":"2017-07-25T12:11:28", "Uptime":68, "Vcc":3.122, "POWER":"POWER", "Wifi":{"AP":1, "SSID":"HotelZurBirke", "RSSI":100, "APMac":"24:65:11:BF:12:D8"}}
tele/tasmota-E8A6E4/ENERGY {"Time":"2017-07-25T12:11:28", "Total":0.640, "Yesterday":0.007, "Today":0.003, "Period":0, "Power":0, "Factor":0.00, "Voltage":0, "Current":0.000}
cmnd/tasmota-E8A6E4/POWER OFF
stat/tasmota-E8A6E4/RESULT {"POWER":"OFF"}
stat/tasmota-E8A6E4/POWER OFF
```