1. Restructured configuration: Moved config_other and console to top level 2. Added common _match_pattern function for regex pattern matching 3. Implemented Unifi Hostname bug fix in is_hostname_unknown 4. Created common get_device_hostname function to eliminate code duplication 5. Added comprehensive test scripts for all new functionality 6. Added detailed documentation for all changes
81 lines
4.0 KiB
Markdown
81 lines
4.0 KiB
Markdown
# Testing the UniFi OS Hostname Bug Check
|
|
|
|
This document provides steps to test the changes made to remove the requirement to only look for the UniFi OS hostname bug in Device mode.
|
|
|
|
## What Changed
|
|
|
|
The code has been modified to check for the UniFi OS hostname bug whenever a device matches an unknown_device_pattern, regardless of whether it's in Device mode or not. This ensures more consistent behavior and better detection of devices affected by the UniFi OS hostname bug.
|
|
|
|
## Test Plan
|
|
|
|
### Test 1: Discovery Mode (get_tasmota_devices)
|
|
|
|
1. Run TasmotaManager in discovery mode with debug logging:
|
|
```bash
|
|
python TasmotaManager.py --debug
|
|
```
|
|
|
|
2. Check the logs for messages about checking device's self-reported hostname:
|
|
- Look for log entries like: "Checking device's self-reported hostname for [device_name]"
|
|
- Look for log entries like: "UniFi OS hostname bug detected for [device_name]: self-reported hostname '[hostname]' doesn't match unknown patterns"
|
|
|
|
3. Examine the current.json file to verify that devices have the `unifi_hostname_bug_detected` flag set correctly:
|
|
```bash
|
|
grep -A 5 "unifi_hostname_bug_detected" current.json
|
|
```
|
|
|
|
### Test 2: Device Mode (process_single_device)
|
|
|
|
1. Find a device that matches an unknown_device_pattern but has a proper self-reported hostname:
|
|
- This could be a device that was recently renamed but UniFi still shows the old name
|
|
- Or a device that has a generic name in UniFi but a proper hostname on the device itself
|
|
|
|
2. Run TasmotaManager in Device mode with the device's hostname or IP and debug logging:
|
|
```bash
|
|
python TasmotaManager.py --Device [hostname_or_ip] --debug
|
|
```
|
|
|
|
3. Check the logs for messages about checking device's self-reported hostname:
|
|
- Look for log entries like: "Checking device's self-reported hostname before declaring unknown"
|
|
- Look for log entries like: "Device NOT declared as unknown: self-reported hostname doesn't match unknown patterns (possible UniFi OS bug)"
|
|
|
|
4. Examine the TasmotaDevices.json file to verify that the device has the `unifi_hostname_bug_detected` flag set correctly:
|
|
```bash
|
|
grep -A 5 "unifi_hostname_bug_detected" TasmotaDevices.json
|
|
```
|
|
|
|
### Test 3: Hostname Mode (process_single_device with hostname)
|
|
|
|
1. Find a device that matches an unknown_device_pattern but has a proper self-reported hostname.
|
|
|
|
2. Run TasmotaManager in Device mode with the device's hostname (not IP) and debug logging:
|
|
```bash
|
|
python TasmotaManager.py --Device [hostname] --debug
|
|
```
|
|
|
|
3. Check the logs to verify that the hostname bug check is still performed even though we're not using an IP address directly:
|
|
- Look for log entries like: "Checking device's self-reported hostname before declaring unknown"
|
|
|
|
4. Examine the TasmotaDevices.json file to verify that the device has the `unifi_hostname_bug_detected` flag set correctly.
|
|
|
|
## Expected Results
|
|
|
|
- The hostname bug check should be performed for all devices that match unknown_device_patterns, regardless of whether they're processed in discovery mode or device mode.
|
|
- The `unifi_hostname_bug_detected` flag should be set to `true` for devices where:
|
|
1. The UniFi-reported name matches an unknown_device_pattern
|
|
2. The device's self-reported hostname does NOT match any unknown_device_pattern
|
|
- The device should NOT be declared as unknown if its self-reported hostname doesn't match any unknown_device_pattern, even if its UniFi-reported name does.
|
|
|
|
## Troubleshooting
|
|
|
|
If the tests don't produce the expected results:
|
|
|
|
1. Verify that the device actually matches an unknown_device_pattern in UniFi:
|
|
- Check the device's name and hostname in UniFi
|
|
- Compare with the patterns in network_configuration.json
|
|
|
|
2. Verify that the device's self-reported hostname doesn't match any unknown_device_pattern:
|
|
- You can manually check this by accessing the device's web interface
|
|
- Or by running: `curl http://[device_ip]/cm?cmnd=Status%205`
|
|
|
|
3. Check for any errors in the logs that might indicate issues with connecting to the device or parsing its response. |