Update TasmotaManager with console parameters and documentation
This commit is contained in:
parent
d566a7fdbb
commit
301eb03c3e
84
CONSOLE_COMMANDS.md
Normal file
84
CONSOLE_COMMANDS.md
Normal file
@ -0,0 +1,84 @@
|
||||
# Tasmota Console Commands Documentation
|
||||
|
||||
This document provides detailed information about the console commands used in the `network_configuration.json` file, particularly focusing on the SetOptions commands.
|
||||
|
||||
## Console Section in network_configuration.json
|
||||
|
||||
The `console` section in the `network_configuration.json` file allows you to configure various Tasmota device settings through the TasmotaManager script. These settings are applied to all devices during the version check process.
|
||||
|
||||
```json
|
||||
"console": {
|
||||
"SwitchRetain": "Off",
|
||||
"ButtonRetain": "Off",
|
||||
"PowerOnState": "3",
|
||||
"PowerRetain": "On",
|
||||
"SetOption1": "0",
|
||||
"SetOption3": "1",
|
||||
"SetOption13": "0",
|
||||
"SetOption19": "0",
|
||||
"SetOption32": "8",
|
||||
"SetOption53": "1",
|
||||
"SetOption73": "1",
|
||||
"rule1": "on button1#state=10 do power0 toggle endon",
|
||||
"rule2": "1"
|
||||
}
|
||||
```
|
||||
|
||||
## MQTT Retain Settings
|
||||
|
||||
| Command | Values | Description |
|
||||
|---------|--------|-------------|
|
||||
| `SwitchRetain` | `On`, `Off` | Controls whether MQTT retain flag is used on switch press messages. Default: `Off` |
|
||||
| `ButtonRetain` | `On`, `Off` | Controls whether MQTT retain flag is used on button press messages. Default: `Off` |
|
||||
| `PowerRetain` | `On`, `Off` | Controls whether MQTT retain flag is used on power state messages. Default: `Off` |
|
||||
|
||||
## Power Settings
|
||||
|
||||
| Command | Values | Description |
|
||||
|---------|--------|-------------|
|
||||
| `PowerOnState` | `0` to `4` | Controls the power state when the device is powered up:<br>`0` = Off<br>`1` = On<br>`2` = Toggle<br>`3` = Last state (default)<br>`4` = Turn on if off after restart |
|
||||
|
||||
## SetOptions
|
||||
|
||||
SetOptions are special commands that control various aspects of Tasmota device behavior. Below are the SetOptions currently used in the configuration:
|
||||
|
||||
| Command | Values | Description |
|
||||
|---------|--------|-------------|
|
||||
| `SetOption1` | `0`, `1` | Controls whether a button press toggles power or sends a MQTT message:<br>`0` = toggle power (default)<br>`1` = send MQTT message |
|
||||
| `SetOption3` | `0`, `1` | Controls MQTT enabled/disabled:<br>`0` = disable MQTT<br>`1` = enable MQTT (default) |
|
||||
| `SetOption13` | `0`, `1` | Controls whether a button press clears retained messages:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption19` | `0`, `1` | Controls Home Assistant auto-discovery:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption32` | `1` to `250` | Time in minutes to hold relay latching power before reset. Default: `1` |
|
||||
| `SetOption53` | `0`, `1` | Controls display of hostname and IP address in GUI:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption73` | `0`, `1` | Controls whether HTTP cross-origin resource sharing is enabled:<br>`0` = disable (default)<br>`1` = enable |
|
||||
|
||||
## Additional SetOptions
|
||||
|
||||
Here are some other useful SetOptions that can be added to the configuration:
|
||||
|
||||
| Command | Values | Description |
|
||||
|---------|--------|-------------|
|
||||
| `SetOption0` | `0`, `1` | Save power state and use after restart:<br>`0` = disable<br>`1` = enable (default) |
|
||||
| `SetOption4` | `0`, `1` | Return MQTT response as RESULT or %COMMAND%:<br>`0` = RESULT (default)<br>`1` = %COMMAND% |
|
||||
| `SetOption8` | `0`, `1` | Show temperature in Celsius or Fahrenheit:<br>`0` = Celsius (default)<br>`1` = Fahrenheit |
|
||||
| `SetOption10` | `0`, `1` | When the device restarts, the LWT message is sent:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption11` | `0`, `1` | Swap button single and double press functionality:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption20` | `0`, `1` | Update of Hass discovery messages:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption30` | `0`, `1` | Enforce Home Assistant auto-discovery as light:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption31` | `0`, `1` | Disable status LED blinking during Wi-Fi and MQTT connection issues:<br>`0` = LED enabled (default)<br>`1` = LED disabled |
|
||||
| `SetOption36` | `0` to `255` | Boot loop control:<br>`0` = disable (default)<br>`1` to `200` = enable with number of boot loops before entering safe mode |
|
||||
| `SetOption52` | `0`, `1` | Control display of optional time offset from UTC in JSON messages:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption65` | `0`, `1` | Device recovery using fast power cycle detection:<br>`0` = disable (default)<br>`1` = enable |
|
||||
| `SetOption80` | `0`, `1` | Enable Alexa support for devices with an ESP8266 over 1M flash:<br>`0` = disable<br>`1` = enable (default) |
|
||||
| `SetOption82` | `0`, `1` | Reduce the CT range from 153..500 to 200..380 to accommodate with Alexa:<br>`0` = CT ranges from 153 to 500 (default)<br>`1` = CT ranges from 200 to 380 (Alexa compatible) |
|
||||
|
||||
## Rules
|
||||
|
||||
Rules allow you to create simple automations directly on the Tasmota device.
|
||||
|
||||
| Command | Values | Description |
|
||||
|---------|--------|-------------|
|
||||
| `rule1` | Rule expression | Defines the first rule. Example: `on button1#state=10 do power0 toggle endon` |
|
||||
| `rule2` | `0`, `1` | Enables or disables rule2:<br>`0` = disable (default)<br>`1` = enable |
|
||||
|
||||
For more information about Tasmota commands, visit the [official Tasmota documentation](https://tasmota.github.io/docs/Commands/).
|
||||
14
README.md
14
README.md
@ -5,7 +5,7 @@ A Python utility for discovering, monitoring, and managing Tasmota devices on a
|
||||
## Features
|
||||
|
||||
- Discovers Tasmota devices on the network via UniFi Controller API
|
||||
- Tracks device changes over time (new, moved, deprecated devices)
|
||||
- Track device changes over time (new, moved, deprecated devices)
|
||||
- Checks and updates MQTT settings on Tasmota devices
|
||||
- Generates detailed device information including firmware versions
|
||||
- Processes unknown devices (matching unknown_device_patterns) to set up names and MQTT
|
||||
@ -107,7 +107,7 @@ The script can process devices that match patterns in the `unknown_device_patter
|
||||
|
||||
1. Identify devices matching the unknown device patterns
|
||||
2. Check if each device has a toggle button (indicating it's a light switch or power plug)
|
||||
3. Toggle the button at 1/2Hz (on/off every two seconds) to help identify the physical device
|
||||
3. Toggle the button at 1/2 Hz (on/off every two seconds) to help identify the physical device
|
||||
4. **How to enter the hostname:**
|
||||
- The script will display a clear prompt in the console showing the current device name and IP address
|
||||
- While the device is toggling, you'll see a prompt asking for a new name for the device
|
||||
@ -133,6 +133,16 @@ The script supports setting Tasmota console parameters via the `console` section
|
||||
|
||||
Each parameter is sent as a command to the device using the Tasmota HTTP API. The device details in `TasmotaDevices.json` will include a `console_status` field indicating whether console parameters were updated.
|
||||
|
||||
For detailed documentation of all available SetOptions and other console commands, please refer to the [CONSOLE_COMMANDS.md](CONSOLE_COMMANDS.md) file. This documentation includes:
|
||||
|
||||
- Explanations of all SetOptions currently used in the configuration
|
||||
- Additional useful SetOptions that can be added
|
||||
- MQTT retain settings
|
||||
- Power settings
|
||||
- Rules configuration
|
||||
|
||||
The documentation is based on the official [Tasmota Commands Reference](https://tasmota.github.io/docs/Commands/#setoptions).
|
||||
|
||||
## Output Files
|
||||
|
||||
The script generates several output files:
|
||||
|
||||
@ -724,7 +724,38 @@ class TasmotaDiscovery:
|
||||
console_params = mqtt_config.get('console', {})
|
||||
if console_params:
|
||||
self.logger.info(f"{name}: Setting console parameters from configuration")
|
||||
|
||||
# Special handling for ButtonRetain - need to send "On" first, then "Off" to clear MQTT broker retain settings
|
||||
try:
|
||||
# First ButtonRetain command (On)
|
||||
url = f"http://{ip}/cm?cmnd=ButtonRetain%20On"
|
||||
response = requests.get(url, timeout=5)
|
||||
if response.status_code == 200:
|
||||
self.logger.debug(f"{name}: Set ButtonRetain to On (step 1 of 2 to clear MQTT broker retain settings)")
|
||||
console_updated = True
|
||||
else:
|
||||
self.logger.error(f"{name}: Failed to set ButtonRetain to On")
|
||||
|
||||
# Small delay to ensure commands are processed in order
|
||||
time.sleep(0.5)
|
||||
|
||||
# Second ButtonRetain command (Off)
|
||||
url = f"http://{ip}/cm?cmnd=ButtonRetain%20Off"
|
||||
response = requests.get(url, timeout=5)
|
||||
if response.status_code == 200:
|
||||
self.logger.debug(f"{name}: Set ButtonRetain to Off (step 2 of 2 to clear MQTT broker retain settings)")
|
||||
console_updated = True
|
||||
else:
|
||||
self.logger.error(f"{name}: Failed to set ButtonRetain to Off")
|
||||
except requests.exceptions.RequestException as e:
|
||||
self.logger.error(f"{name}: Error setting ButtonRetain commands: {str(e)}")
|
||||
|
||||
# Process all other console parameters
|
||||
for param, value in console_params.items():
|
||||
# Skip ButtonRetain as it's handled specially above
|
||||
if param == "ButtonRetain":
|
||||
continue
|
||||
|
||||
try:
|
||||
url = f"http://{ip}/cm?cmnd={param}%20{value}"
|
||||
response = requests.get(url, timeout=5)
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
"console": {
|
||||
"SwitchRetain": "Off",
|
||||
"ButtonRetain": "Off",
|
||||
"PowerOnState": "3",
|
||||
"PowerRetain": "On",
|
||||
"PowerOnState": "3",
|
||||
"SetOption1": "0",
|
||||
"SetOption3": "1",
|
||||
"SetOption13": "0",
|
||||
@ -41,7 +41,7 @@
|
||||
"SetOption53": "1",
|
||||
"SetOption73": "1",
|
||||
"rule1": "on button1#state=10 do power0 toggle endon",
|
||||
"rule1": "1"
|
||||
"rule2": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user