TasmotaManager/docs/summaries/console_settings_summary.md
2025-10-28 00:21:08 +00:00

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

  1. Modified the configure_unknown_device method in TasmotaManager.py to:

    • 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
  2. Created a test script test_unknown_device_console_settings.py to 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_device method
    • 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:

  1. 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
  2. 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
  3. 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:

  1. Display the console parameters from the configuration
  2. Process the device, applying hostname, MQTT settings, and console settings
  3. Report whether the processing was successful

Expected Behavior

After this change, when an unknown device is processed:

  1. The hostname and MQTT settings will be updated
  2. All console settings from the configuration will be applied
  3. The device will be rebooted
  4. Upon restart, the device will have all settings properly configured