Commit Graph

71 Commits

Author SHA1 Message Date
be95930cd1 Fix MQTT FullTopic with URL-encoded leading space
- Devices had FullTopic starting with %20 (URL-encoded space)
- This breaks MQTT topic publishing with invalid leading space
- Now detects %20 prefix and forces update even if normalized values match
- Properly URL-encodes all MQTT setting values when sending
- FullTopic %prefix%/%topic%/ now encoded as %25prefix%25%2F%25topic%25%2F
- Fixes MQTT topics showing as '%20stat/device/...' instead of 'stat/device/...'
2026-01-07 21:05:20 -06:00
12ebdbf3e9 Improve rule enabling reliability
- Add 0.5s delay before enabling rule to let device process rule content
- Use retry logic for rule enable command (3 attempts with 1s delay)
- Change failed enable from warning to error and fail the command
- Ensures rules are both set AND enabled for switches to work
2026-01-07 20:36:28 -06:00
70e0b038e6 Fix device matching to check template NAME field
- DeviceName comes from template's NAME field (e.g., 'Treatlife SS02')
- Config keys use different names (e.g., 'TreatLife_SW_SS02S')
- Now falls back to checking template NAME if key doesn't match
- Fixes issue where devices with template-based names weren't getting console settings
- Both console_settings and device_diff use same matching logic
2026-01-07 20:30:53 -06:00
137899cfc2 Fix rule commands by properly URL-encoding special characters
- Changed from simple space replacement to full URL encoding using quote()
- Rules contain # and = characters that must be encoded
- # was being treated as URL fragment, truncating rule commands
- Now encodes # as %23, = as %3D, spaces as %20, etc.
- Fixes issue where rules weren't being applied correctly to devices
2026-01-07 20:14:58 -06:00
7f00bb8d7b Add single-device comparison to config file
- Modified --diff to accept 1 or 2 device arguments
- With 1 device: compares device config vs expected config from file
- With 2 devices: compares devices to each other (existing behavior)
- Shows which SetOptions and Rules don't match configuration
- Normalizes ON/OFF vs 1/0 for proper comparison
- Helps diagnose why console settings aren't applying correctly
2026-01-07 20:09:26 -06:00
72b21bc838 Disable SetOption verification to prevent overwhelming devices
- Verification was doubling the number of HTTP requests per setting
- Devices were refusing connections due to request overload
- Trust command success based on response, don't verify separately
- Fixes connection refused and timeout errors
2026-01-07 19:58:04 -06:00
c1eb707519 Revert "Add delays and retry logic for SetOption verification"
This reverts commit 794eb4319b.
2026-01-07 19:57:47 -06:00
794eb4319b Add delays and retry logic for SetOption verification
- Wait 0.5s after sending command before first verification
- Retry verification once with 0.5s delay if first attempt fails
- Increase delay between commands from 0.3s to 0.5s
- Add delay after enabling rules
- Prevents false verification failures by giving device time to process
- Avoids overwhelming device with rapid command sequences
2026-01-07 19:52:32 -06:00
73acc41145 Fix SetOption verification to handle ON/OFF vs 1/0 responses
- Tasmota returns 'ON'/'OFF' for SetOption queries
- Config file uses '1'/'0' for SetOption values
- Added normalize_value() to convert both formats to comparable values
- Eliminates false verification warnings for correctly applied settings
2026-01-04 22:30:43 -06:00
265fa33497 Fix console settings matching to use DeviceName instead of Hostname
- Changed from using Hostname base (e.g., 'KitchenBar') to DeviceName (e.g., 'TreatLife_SW_SS02S')
- DeviceName matches the template names in device_list configuration
- This fixes issue where console settings weren't being applied correctly
- Devices were not matching any templates due to hostname vs device type mismatch
- Now uses exact match first, then case-insensitive fallback
2026-01-04 16:17:06 -06:00
80b55b6b43 Fix SetOption32 in SONOFF_ULTIMATE profile to match working Traditional profile
- Changed SetOption32 from 8 to 40 in SONOFF_ULTIMATE profile
- This fixes button timing issues where multiple presses were required
- KitchenMain (Traditional profile) was already using 40 and working correctly
- KitchenBar (SONOFF_ULTIMATE profile) had 8 and required multiple presses
- Both profiles now use SetOption32=40 (4 second hold time)
2026-01-04 13:12:19 -06:00
c2800ce646 Change rule differences to columnar format for easier field comparison
- Display rule fields side-by-side in columns like other sections
- Makes it easier to compare State, Once, Length, Free, Rules, etc.
- Consistent formatting with rest of report
2026-01-04 12:52:44 -06:00
3ea2798857 Improve report formatting: compact sections and row format for rules
- Remove extra lines between section headers and content
- Add blank lines only after sections for better readability
- Add _print_rule_differences() method to display rules in row format
- Rules show device names as rows with detailed rule info below each
- More space-efficient report layout
2026-01-04 11:32:00 -06:00
cacdfe7a77 Improve --diff report output with columnar format
Enhanced readability with table-style columnar output

Changes:
- Converted vertical list format to columnar table format
- First column: Parameter name
- Second column: Device 1 value
- Third column: Device 2 value
- Added header row with device names
- Auto-adjusts column widths based on content
- Truncates very long values (>60 chars) with "..."
- Maintains section separation (Firmware, Network, MQTT, etc.)

Before:
  SetOption32:
    KitchenMain = 40
    KitchenBar  = 8

After:
  Parameter        KitchenMain-3040      KitchenBar-7845
  ---------------  --------------------  --------------------
  SetOption32      40                    8

Much easier to scan and compare values side-by-side!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 11:22:43 -06:00
91c471d4b0 Parallelize device queries in --diff feature for faster comparison
Performance Improvement: Query both devices simultaneously

Changes:
- Added ThreadPoolExecutor to device_diff.py compare_devices()
- Both devices are now queried in parallel (max 2 workers)
- Each device queries ~150+ SetOptions independently
- Roughly 2x faster than sequential queries

Before: ~30 seconds (sequential)
After: ~15 seconds (parallel)

The parallel approach significantly improves user experience when comparing
devices, especially when querying all SetOptions (0-150) and Rules.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 11:17:57 -06:00
49cf1ec789 Add --diff feature to compare two Tasmota devices
New Feature: Device configuration comparison tool for diagnostics

Usage:
  python TasmotaManager.py --diff DEVICE1 DEVICE2

Features:
- Queries all SetOptions (0-150) from both devices
- Compares firmware versions, network config, MQTT settings
- Shows Rule configurations and status
- Displays all differences in human-readable format
- Helps diagnose configuration issues between working/non-working devices

Files Added:
- device_diff.py: New DeviceComparison class with full status queries

Files Modified:
- TasmotaManager.py: Added --diff argument and comparison mode handler

Example:
  python TasmotaManager.py --diff KitchenMain KitchenBar

This tool revealed that KitchenMain (working) and KitchenBar (problematic)
have significant SetOption differences including SetOption32, SetOption40,
and others that may affect button press behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 11:10:24 -06:00
65147fe4be Fix button press timing issue - Rule Once flag was causing single-fire
Root Cause: console_settings.py was using "Rule{N} 1" command which BOTH
enables the rule AND sets the Once flag to ON. The Once flag causes rules
to fire only one time and then stop, requiring multiple button presses
before the rule would work again.

Solution: Changed rule enablement from "Rule{N} 1" to "Rule{N} 4"
- Rule 1 = Enable rule + Set Once ON (WRONG)
- Rule 4 = Enable rule only (CORRECT)
- Rule 5 = Set Once ON only
- Rule 6 = Set Once OFF only

This allows rules to fire repeatedly on every button press, fixing the
issue where devices like KitchenBar required multiple presses.

Changes:
- console_settings.py line 190: Use Rule{N} 4 instead of Rule{N} 1
- Added detailed comments explaining Tasmota rule command behavior
- Reverted SetOption32 changes (was red herring, not the actual issue)

Tested on KitchenBar (192.168.8.244) - button now responds on every press.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 07:07:28 -06:00
8f758599cf Fix button press timing issue by increasing SetOption32 to 40
Issue: Some Tasmota switches (e.g., KitchenBar) required multiple button
presses before responding, while others (e.g., KitchenMain) worked immediately.

Root Cause: SetOption32 was set to 8 (0.8 seconds) which creates too short
a time window for multi-press detection. This causes the device to sometimes
misinterpret single presses or require multiple attempts.

Solution: Changed SetOption32 from 8 to 40 (4.0 seconds) in both Traditional
and SONOFF_ULTIMATE console_set profiles. This matches the working devices
and provides a longer, more reliable detection window for single button presses
when using rule: "on button1#state=10 do power0 toggle endon"

SetOption32 controls the button hold time in 0.1s increments. A higher value
means the device waits longer to confirm it's a single press vs multi-press,
resulting in more reliable single-press detection.

Tested on KitchenBar (192.168.8.244) - button now responds reliably on first press.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 06:53:40 -06:00
2f3fd5d711 Feature: Add parallel device processing and improved error handling
Major changes:
- Implement parallel device processing using ThreadPoolExecutor (10 workers)
- Add comprehensive error and warning tracking in ReportGenerator
- Fix MQTT configuration verification (query Topic/FullTopic directly)
- Improve console settings thread safety with locks
- Fix UniFi client for UniFi OS API endpoints
- Normalize FullTopic handling (strip URL-encoded spaces)
- Update network exclude patterns to support wildcards
- Add test_unifi_connection.py for debugging UniFi connectivity

Performance improvements:
- Process devices concurrently for faster execution
- Reduced verbose logging during parallel processing

Bug fixes:
- Handle deprecated.json format correctly (list vs dict)
- Fix exclude_patterns matching with partial string support
- Fix UniFi API authentication and endpoint paths for UniFi OS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 06:33:21 -06:00
0267b1712b Fix UniFi OS (UDM-SE) API endpoints for client/device queries
UDM-SE uses UniFi OS which requires /proxy/network prefix for Network
application API endpoints. The legacy controller endpoints (/api/s/...)
return 404 on UniFi OS devices.

Changes:
- Updated get_clients() to use /proxy/network/api/s/{site}/stat/sta
- Updated get_devices() to use /proxy/network/api/s/{site}/stat/device
- Added comments explaining UniFi OS API structure

Fixes 404 errors when querying UniFi controller for devices

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 06:16:40 -06:00
c157595ee3 Fix UDM-SE authentication error by skipping meta.rc check for auth endpoint
The authentication endpoint /api/auth/login returns HTTP 200 with a different
JSON response format than data endpoints. UDM-SE (UniFi OS) does not include
the meta.rc field in authentication responses, causing false authentication
failures.

Changes:
- Added skip_meta_check parameter to _request_json() method
- Updated _login() to skip meta.rc validation for auth endpoint
- Added debug logging to show actual API responses for troubleshooting

Fixes authentication error: "UniFi API error: Unknown error"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 06:12:39 -06:00
d42fd83d5d Merge features from Sonoff_TX_Ultimate branch (excluding today's changes) 2025-12-30 11:50:37 -06:00
d2e97d2985 moved the example file to docs director 2025-10-29 17:01:47 +00:00
dec72de4e0 Organize: Move refactoring helper files to docs/
- Moved tasmota_manager_refactor_notes.md to docs/REFACTORING_NOTES.md
- Moved migrate_to_refactored.py to docs/ for future reference
- Moved GitWorkflowRefactor.sh to docs/ for future reference
2025-10-29 16:51:17 +00:00
e8803df329 Rename main.py to TasmotaManager.py
- Renamed main.py to TasmotaManager.py for consistency with project name
- Updated pyproject.toml to reflect the new module name
- All functionality remains the same
2025-10-29 16:42:50 +00:00
9c22168f79 Refactor: Split TasmotaManager into modular structure
- Created modular Python files (main, utils, discovery, configuration, console_settings, unknown_devices, reporting, unifi_client)
- Moved documentation files to docs/
- Moved data files to data/
- Removed old monolithic TasmotaManager.py and TasmotaManager_fixed.py
- Updated .gitignore and pyproject.toml
- All functionality preserved, command-line interface unchanged
Version: 2.0.0
2025-10-29 16:38:03 +00:00
9764d28b04 Update KNOWN_ISSUES.md: Mark Issue #5 as resolved 2025-10-28 09:50:54 +00:00
8637c89e65 Fix Issue #5: Remove empty string from Traditional console_set
- Removed blank entry that was causing empty parameter errors
- Fixes 'Verification failed for blank parameter' errors on all devices
- Issue discovered during testing and root cause identified in config
2025-10-28 09:47:01 +00:00
bc384f6b9c Fix Issue #3: Add delay after MQTT configuration before console settings
- Add 1-second delay after MQTT changes to allow device to process
- Only delays when MQTT settings were actually updated
- Prevents intermittent failures when applying console settings
- Device needs time to process MQTT reconnection before accepting new commands
2025-10-28 08:54:17 +00:00
4d510688ab Fix Issue #1: Ensure template activation with Module 0 verification
- Add 0.5s delays after Template and Module commands for device processing
- Verify Module=0 (activation) in post-update verification, not just template
- Apply fixes to both template update and device name update code paths
- Enhanced logging for Module operations and verification
- Fixes issue where template was set but not activated, leaving device inoperable
2025-10-28 08:39:15 +00:00
8b05031e2e moving items around 2025-10-28 00:21:08 +00:00
8603cd3e7e Added ignore rules 2025-10-26 12:45:08 -05:00
3e66920c2a Stage network_configuration.json for git: ensure updated device_list formatting and console_set profiles are committed 2025-08-28 08:41:16 -05:00
35e6098a61 Save latest session changes: migrate to console_set profiles, device_list structure with per-device console_set, docs updated, formatting updates 2025-08-28 08:07:29 -05:00
8b42e7435e Merge branch 'inital' into 'master'
Inital

See merge request tasmota/manager!31
2025-08-17 21:58:31 +00:00
142d825909 Release V1.00 2025-08-17 16:47:03 -05:00
d4b29c2359 Console settings: add post-update verification in with_retry flows; introduce _verify_console_param_value and use it to verify retain final state, general params, and RuleN enable; keep non-retry path behavior. Improves reliability and ensures updates actually took. 2025-08-09 11:01:58 -05:00
9646099a4f UniFi hostname bug handling: keep UniFi name in discovery listing for compatibility, but use device self-reported hostname for operations when bug detected.\n- get_tasmota_devices: detect bug and log self-reported hostname without overwriting listing fields.\n- process_single_device: prefer self-reported hostname for subsequent processing/logs.\n- get_device_details: on bug flag, use self-reported hostname (op_name) for MQTT/console/template updates so %hostname_base% derives from correct name.\n- Add informative logs showing override decisions.\nTargeted tests pass: unifi hostname bug fix/flag and device discovery. 2025-08-08 23:59:23 -05:00
8de801c324 Unifi hostname bug: use self-reported hostname base (before '-') for unknown pattern comparison in bug detection across is_hostname_unknown, get_tasmota_devices, and process_single_device. Add exception handling in is_hostname_unknown for request failures. All targeted tests pass. 2025-08-08 23:31:55 -05:00
c31bcbdf85 Console updates: add idempotent pre-checks before sending commands; skip when values already match. Retain params toggled only if needed; rule definitions compared via RuleN 5; RuleN auto-enable skipped if already ON. Add helper _get_console_param_value. Confirm config_other already conditional. 2025-08-08 23:16:18 -05:00
7d1755b44a Build: add pyproject.toml (PEP 621) with setuptools backend and console script; Docs: explain what it takes to make pyproject.toml and how to build/install. 2025-08-08 22:50:48 -05:00
44c9042eee Docs: FAQ - setup.py not needed to publish on GitHub; clarify hosting vs packaging and mention modern pyproject.toml with link to packaging guide. 2025-08-08 22:47:06 -05:00
3f78ff0bd7 Docs: add 'Publishing a Python Script on GitHub' section with step-by-step instructions. 2025-08-08 22:42:36 -05:00
5784a0b414 Refactor: extract console settings into apply_console_settings(); add apply_config_other wrapper; update get_device_details to use wrapper. Docs: fix Configuration example to separate console and config_other; clarify console section usage. Add dead_functions_summary.md audit confirming no dead functions. 2025-08-08 22:32:09 -05:00
126cd39555 Major code improvements and bug fixes:
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
2025-08-08 19:04:33 -05:00
4b6e0dff93 Add documentation for rule writing fix 2025-08-06 22:44:58 -05:00
2345184a76 Update documentation to include SetOption4 2025-08-06 21:28:19 -05:00
3e6001568f Add detailed reporting when no template match is found 2025-08-06 20:52:15 -05:00
d585f0f284 Implement template activation, fix console settings duplication, and improve connection display 2025-08-06 20:31:57 -05:00
cced5a76cc Fix FullTopic parameter to prevent extra equals sign at beginning of value 2025-08-06 04:30:31 -05:00