Implement console parameters feature to set Tasmota device settings
This commit is contained in:
parent
3d2afbd248
commit
d566a7fdbb
30
README.md
30
README.md
@ -63,7 +63,22 @@ Create a `network_configuration.json` file with the following structure:
|
||||
"Password": "mqtt-password",
|
||||
"Topic": "%hostname_base%",
|
||||
"FullTopic": "%prefix%/%topic%/",
|
||||
"NoRetain": false
|
||||
"NoRetain": false,
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -107,12 +122,23 @@ The script can process devices that match patterns in the `unknown_device_patter
|
||||
|
||||
This feature helps automate the setup of new Tasmota devices that haven't been properly named yet.
|
||||
|
||||
## Console Parameters
|
||||
|
||||
The script supports setting Tasmota console parameters via the `console` section in the MQTT configuration. After verifying and updating MQTT settings, the script will apply all console parameters to each device. This allows you to:
|
||||
|
||||
- Configure device behavior (PowerOnState, SetOptions, etc.)
|
||||
- Set up rules for button actions
|
||||
- Configure retain flags for various message types
|
||||
- Apply any other Tasmota console commands
|
||||
|
||||
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.
|
||||
|
||||
## Output Files
|
||||
|
||||
The script generates several output files:
|
||||
- `current.json`: List of currently active Tasmota devices
|
||||
- `deprecated.json`: Devices that were previously active but are no longer present
|
||||
- `TasmotaDevices.json`: Detailed information about each device
|
||||
- `TasmotaDevices.json`: Detailed information about each device, including MQTT and console parameter status
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@ -718,6 +718,23 @@ class TasmotaDiscovery:
|
||||
|
||||
# Check and update MQTT settings if needed
|
||||
mqtt_updated = check_mqtt_settings(ip, name, mqtt_data)
|
||||
|
||||
# Set console parameters from config
|
||||
console_updated = False
|
||||
console_params = mqtt_config.get('console', {})
|
||||
if console_params:
|
||||
self.logger.info(f"{name}: Setting console parameters from configuration")
|
||||
for param, value in console_params.items():
|
||||
try:
|
||||
url = f"http://{ip}/cm?cmnd={param}%20{value}"
|
||||
response = requests.get(url, timeout=5)
|
||||
if response.status_code == 200:
|
||||
self.logger.debug(f"{name}: Set console parameter {param} to {value}")
|
||||
console_updated = True
|
||||
else:
|
||||
self.logger.error(f"{name}: Failed to set console parameter {param}")
|
||||
except requests.exceptions.RequestException as e:
|
||||
self.logger.error(f"{name}: Error setting console parameter {param}: {str(e)}")
|
||||
|
||||
device_detail = {
|
||||
"name": name,
|
||||
@ -726,6 +743,7 @@ class TasmotaDiscovery:
|
||||
"version": status_data.get("StatusFWR", {}).get("Version", "Unknown"),
|
||||
"hostname": network_data.get("StatusNET", {}).get("Hostname", "Unknown"),
|
||||
"mqtt_status": "Updated" if mqtt_updated else "Verified",
|
||||
"console_status": "Updated" if console_updated else "Verified",
|
||||
"last_checked": time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"status": "online"
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
"NoRetain": false,
|
||||
"console": {
|
||||
"SwitchRetain": "Off",
|
||||
"ButtonRetain": "On",
|
||||
"ButtonRetain": "Off",
|
||||
"PowerOnState": "3",
|
||||
"PowerRetain": "On",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user