64 lines
3.2 KiB
Markdown
64 lines
3.2 KiB
Markdown
# UniFi OS Hostname Tracking Fix
|
|
|
|
## Issue Description
|
|
|
|
The UniFi OS has an issue with keeping track of host names. If a hostname is updated and the connection reset, UniFi will not keep track of the new name. When in Device mode, when the user enters a new hostname, the script updates the name, but UniFi OS may not pick up the new name.
|
|
|
|
## Solution Implemented
|
|
|
|
A new feature has been added to the TasmotaManager.py script to address this issue. The solution works as follows:
|
|
|
|
1. When in Device mode (processing by IP) and a device's hostname or name matches an unknown_device_pattern:
|
|
- The script now checks the device's self-reported hostname before declaring it as unknown
|
|
- It makes an HTTP request to the device using the Tasmota Status 5 command to get network information
|
|
- It extracts the self-reported hostname from the response
|
|
|
|
2. Decision logic:
|
|
- If the device's self-reported hostname also matches an unknown_device_pattern, the device is declared as unknown (both UniFi and device agree)
|
|
- If the device's self-reported hostname does NOT match any unknown_device_pattern, the device is NOT declared as unknown (assuming UniFi OS bug)
|
|
- If the device doesn't respond or there's an error getting the self-reported hostname, the script falls back to using the UniFi-reported name
|
|
|
|
3. Error handling:
|
|
- HTTP request failures
|
|
- JSON parsing errors
|
|
- Missing hostname in response
|
|
- Other exceptions
|
|
|
|
## Code Changes
|
|
|
|
The main changes were made in the `process_single_device` method in TasmotaManager.py:
|
|
|
|
1. Renamed the original hostname check result to `unifi_name_matches_unknown` to distinguish it from the final `is_unknown` determination
|
|
2. Added code to check the device's self-reported hostname when in Device mode
|
|
3. Implemented the decision logic described above
|
|
4. Added detailed logging to track the decision-making process
|
|
5. Added comments explaining the purpose of the feature
|
|
|
|
## Testing
|
|
|
|
To test this feature in a real environment:
|
|
|
|
1. Find a device that has been renamed but UniFi still shows the old name
|
|
2. Run TasmotaManager in Device mode with the IP address of the device
|
|
3. Verify that the script correctly identifies the device's self-reported hostname
|
|
4. Confirm that the device is not declared as unknown if its self-reported hostname doesn't match unknown_device_patterns
|
|
|
|
## Benefits
|
|
|
|
This enhancement improves the user experience by:
|
|
|
|
1. Reducing false positives when identifying unknown devices
|
|
2. Working around the UniFi OS bug that doesn't properly track hostname changes
|
|
3. Providing more accurate device identification in Device mode
|
|
4. Adding detailed logging to help troubleshoot hostname-related issues
|
|
|
|
## Alternative Solution for UDM-SE
|
|
|
|
For UDM-SE devices specifically, there is an alternative workaround to force UniFi to recognize new host names:
|
|
|
|
1. Navigate to the UDM-SE admin interface
|
|
2. Go to "Settings/Control Plane/Console/Restart"
|
|
3. Restart the UDM-SE
|
|
4. When the UDM-SE comes back online (which takes several minutes), it will have the updated host names
|
|
|
|
This method can be useful in situations where the script's built-in workaround is not sufficient or when you need to ensure that all devices have their correct hostnames recognized by the UniFi controller. |