58 lines
2.1 KiB
Python
Executable File
58 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify that console settings are applied to unknown devices
|
|
before rebooting. This script will process a single device by IP address
|
|
or hostname and apply console settings from the configuration.
|
|
"""
|
|
|
|
import sys
|
|
import logging
|
|
import argparse
|
|
from TasmotaManager import TasmotaDiscovery
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.DEBUG, # Use DEBUG level to see all console settings being applied
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
|
|
def main():
|
|
"""Main function to test the unknown device console settings functionality."""
|
|
parser = argparse.ArgumentParser(description='Test unknown device console settings')
|
|
parser.add_argument('device_identifier', help='IP address or hostname of the device to test')
|
|
parser.add_argument('--debug', action='store_true', help='Enable debug mode')
|
|
args = parser.parse_args()
|
|
|
|
print(f"Testing unknown device console settings for: {args.device_identifier}")
|
|
|
|
# Initialize TasmotaDiscovery with debug mode if requested
|
|
discovery = TasmotaDiscovery(debug=args.debug)
|
|
|
|
# Load configuration
|
|
discovery.load_config()
|
|
|
|
# Get console settings from configuration
|
|
mqtt_config = discovery.config.get('mqtt', {})
|
|
console_params = mqtt_config.get('console', {})
|
|
|
|
if not console_params:
|
|
print("No console parameters found in configuration. Please add some to test.")
|
|
sys.exit(1)
|
|
|
|
print("Console parameters that will be applied:")
|
|
for param, value in console_params.items():
|
|
print(f" {param}: {value}")
|
|
|
|
# Process the single device
|
|
print("\nProcessing device...")
|
|
result = discovery.process_single_device(args.device_identifier)
|
|
|
|
if result:
|
|
print(f"\nSuccessfully processed device: {args.device_identifier}")
|
|
print("Console settings should have been applied before reboot.")
|
|
else:
|
|
print(f"\nFailed to process device: {args.device_identifier}")
|
|
print("Check the logs for more information.")
|
|
|
|
if __name__ == "__main__":
|
|
main() |