2.5 KiB
Console Settings for Unknown Devices - Implementation Summary
Requirement
For all unknown devices, once the MQTT and hostname are updated but before the reboot, continue with the console settings. Then reboot the device.
Changes Made
-
Modified the
configure_unknown_devicemethod inTasmotaManager.pyto:- Apply console settings from the configuration after setting MQTT parameters but before rebooting
- Handle special cases for retain parameters (ButtonRetain, SwitchRetain, PowerRetain)
- Auto-enable rules that are defined in the configuration
- Maintain the same logging and error handling as the rest of the application
-
Created a test script
test_unknown_device_console_settings.pyto verify the functionality:- The script takes a device identifier (IP or hostname) as an argument
- It displays the console parameters that will be applied from the configuration
- It processes the device using the modified
configure_unknown_devicemethod - This allows testing that console settings are applied to unknown devices before rebooting
Implementation Details
Console Settings Application
The implementation applies console settings in the following order:
-
First, it handles retain parameters (ButtonRetain, SwitchRetain, PowerRetain) with special logic:
- For each retain parameter, it first sets the opposite state
- Then it sets the desired state
- This ensures the MQTT broker's retain flags are properly updated
-
Next, it processes all other console parameters:
- It identifies rule definitions (rule1, rule2, etc.) for auto-enabling
- It applies each parameter with a simple HTTP request
-
Finally, it auto-enables any rules that were defined:
- If a rule definition (e.g., rule1) is found, it automatically enables the rule (Rule1 ON)
- This ensures rules are active after the device reboots
Testing
To test this functionality:
./test_unknown_device_console_settings.py <device_identifier>
Where <device_identifier> is either the IP address or hostname of the device you want to process.
The test script will:
- Display the console parameters from the configuration
- Process the device, applying hostname, MQTT settings, and console settings
- Report whether the processing was successful
Expected Behavior
After this change, when an unknown device is processed:
- The hostname and MQTT settings will be updated
- All console settings from the configuration will be applied
- The device will be rebooted
- Upon restart, the device will have all settings properly configured