44 lines
1.7 KiB
Markdown
44 lines
1.7 KiB
Markdown
# FullTopic Parameter Fix Summary
|
|
|
|
## Issue Description
|
|
When setting the MQTT parameters for FullTopic, the Full Topic was ending up with a %20 at the beginning, as in "%20%prefix%/%topic%/" instead of the correct "%prefix%/%topic%/".
|
|
|
|
## Root Cause
|
|
The issue was in the URL construction when sending commands to Tasmota devices. The code was using a space (%20 in URL encoding) between the command name and its value for all parameters:
|
|
|
|
```python
|
|
url = f"http://{ip}/cm?cmnd={setting}%20{value}"
|
|
```
|
|
|
|
While this works for most parameters, it causes problems with the FullTopic parameter because the space gets included in the value.
|
|
|
|
## Fix Implemented
|
|
The fix adds special handling for the FullTopic parameter by using "=" instead of a space (%20) between the command and value:
|
|
|
|
```python
|
|
# For FullTopic, we need to avoid adding a space (%20) between the command and value
|
|
if setting == "FullTopic":
|
|
url = f"http://{ip}/cm?cmnd={setting}={value}"
|
|
else:
|
|
url = f"http://{ip}/cm?cmnd={setting}%20{value}"
|
|
```
|
|
|
|
This change was implemented in two places:
|
|
1. In the `configure_unknown_device` method (around line 542)
|
|
2. In the MQTT settings update code (around line 937)
|
|
|
|
## Testing
|
|
A test script `test_fulltopic_fix.py` was created to verify the fix. The script:
|
|
1. Connects to a Tasmota device
|
|
2. Sets the FullTopic parameter using the new method
|
|
3. Verifies that the FullTopic is set correctly without the %20 prefix
|
|
|
|
To run the test:
|
|
```
|
|
./test_fulltopic_fix.py <ip_address>
|
|
```
|
|
|
|
Where `<ip_address>` is the IP address of a Tasmota device to test with.
|
|
|
|
## Expected Result
|
|
After this fix, the FullTopic parameter should be set correctly as "%prefix%/%topic%/" without the unwanted %20 at the beginning. |