TasmotaManager/mqtt_device_mode_analysis.txt

31 lines
1.9 KiB
Plaintext

MQTT Command Handling in Device Mode Analysis
When using the --Device parameter to process a single device, the code follows these paths:
1. For normal devices (not matching unknown_device_patterns):
- The process_single_device method creates a temporary current.json with just the target device
- It then calls get_device_details(use_current_json=True)
- get_device_details loads the device from current.json, filters out unknown devices, and processes the remaining devices
- For each device, it sends MQTT commands to configure MQTT settings (Host, Port, User, Password, Topic, FullTopic)
- It also sends commands to configure console parameters, including Retain settings and rules
- All commands have retry logic with up to 3 attempts
2. For unknown devices (matching unknown_device_patterns):
- The process_single_device method identifies the device as unknown
- It then calls configure_unknown_device
- configure_unknown_device sets the Friendly Name, enables MQTT, and configures MQTT settings
- It also configures console parameters, including Retain settings and rules
- Finally, it reboots the device to save the configuration
- Commands do not have retry logic
Conclusion:
All MQTT commands are being sent in Device mode, but there are two different paths depending on whether the device matches an unknown_device_pattern:
1. Normal devices: Processed by get_device_details with retry logic
2. Unknown devices: Processed by configure_unknown_device without retry logic, and the device is rebooted
The main differences are:
1. Retry logic: Only normal devices have retry logic for commands
2. Device reboot: Only unknown devices are rebooted
3. Command failure tracking: Only normal devices track command failures for reporting
These differences are by design, as unknown devices are being initially configured while normal devices are being verified/updated.