Add diagnostic sensors and quality fixes#123
Conversation
|
Pushed two follow-up commits:
|
|
Hello and thanks for submitting this! I'll take a look properly at the weekend. I'm hesistant to add too many diagnostic entities that inflate the integration, without good reason. Are you able to explain your use case for them and how they have helped you out? Specifically Connection Status, Lock Status, Traversal Speed, Model and Last Connection Error? |
|
Hey, thanks for the review! No rush at all, I know it's a big one, and there's another PR coming too, so take your time 😊 Zero impact on performance. The entities only update when the blind already fires a BLE event (no extra polling, no new connections, nothing added to the loop). They're all diagnostic=True as well, so hidden from the default entity list (won't pollute anyone's dashboard). Each one has a specific use case, but I'll give you my motivation about why I wanted to implement them:
And users can always disable any of them individually if they don't need them. Let me know what you think. Thanks |
|
For what it's worth as a user I would like these included. Nice addition from my perspective 👍 |
- Add .gitignore excluding __pycache__, *.pyc, .venv/, .pytest_cache, .DS_Store, *.log - Remove previously tracked __pycache__ directories and test_debug.log
Replace inline hex literals throughout hub.py with named constants in const.py. Improves readability and protects against typos like the limits_step_down bug that previously sent CMD_LIMITS_STEP_UP. Also adds set_speed default case to prevent UnboundLocalError when _blind_speed is unset or unrecognised.
New diagnostic sensors:
- ConnectionStatusSensor: Bluetooth connectivity state (binary)
- LockStatusSensor: blind busy/idle state (binary, LOCK device class)
- TuissModelSensor: blind hardware model
- TuissBlindSpeedSensor: current speed setting (gated by model support)
- TuissLastBatteryCheckSensor: timezone-aware timestamp of last battery check
- TuissBatteryCheckIntervalSensor: configured check interval
- TuissTraversalSpeedSensor: measured traversal speed (% per second)
- TuissLastConnectionErrorSensor: most recent connection error
Quality fixes:
- Seed _blind_speed/_battery_check_days/_restart_attempts from options at
boot. update_listener only fires on option CHANGES, leaving values None
until first edit, which makes set_speed() raise UnboundLocalError and
diagnostic sensors read None.
- Read live model from blind object in options flow. Device registry's
model field is set at registration and may hold the BLE advertisement
name ("Tuiss Smartview") rather than hardware model ("TS2600"),
hiding model-specific options like speed control.
- Switch _last_battery_check to dt_util.now() for timezone awareness.
- Call publish_updates() after option changes and lock state changes so
diagnostic sensors reflect the new value without waiting for a poll.
The test was failing because str(exc.value) on the HomeAssistantError
raised by async_add_timer triggers HA's translation lookup, which
calls async_get_hass() and fails when invoked from a synchronous
test assertion outside a running event loop:
HomeAssistantError: async_get_hass called from the wrong thread
The integration code is correct — the regression is in the test's
choice to stringify the exception. Switch the assertion to read the
translation_key attribute directly (HA stores translation kwargs as
plain attributes on the exception instance) so we never invoke
__str__ and never touch the translation machinery.
Full suite now: 83 passed, 0 failed.
- Drop unused UnitOfTime import in sensor.py - Use CMD_TIMESTAMP_BASE constant in hub.send_timestamp() for consistency with the rest of the BLE-command refactor
4b8bd9f to
51b96c4
Compare
Without persistence, every Home Assistant restart resets _last_battery_check to None, forcing a battery read on the next move regardless of the configured interval. This defeats the purpose of the "battery check days" option. TuissLastBatteryCheckSensor now inherits RestoreEntity and seeds the blind's _last_battery_check from the recorder on entity add.

Hi! 👋
I'm a big fan of this integration — I have several Tuiss blinds at home and rely on it daily. Wanted to contribute back with some quality improvements and a richer set of sensors so I can get more visibility into what each blind is doing.
What's changed
New sensors (more visibility)
Quality fixes
.gitignoreso cache files don't get committedUnder the hood
TRAVERAL→TRAVERSALWhy these changes?
Feedback welcome 🙏
Thanks for building this integration!