LumiSync icon indicating copy to clipboard operation
LumiSync copied to clipboard

feat(power): implement true LED on/off, CLI flag and tests

Open DhanashreePetare opened this issue 2 months ago • 5 comments

[Feature] Added the ability to turn the LEDs off and on #20

Summary:

  1. Added true device power control — sends cmd "turn" with value 0/1.
  2. New helpers: power_on/power_off in devices.py
  3. CLI: --power on|off support in lumisync.py (uses settings or falls back to discovery).
  4. Tests: added test_power_offline.py and test_power_toggle.py; offline tests mock sockets.
  5. GUI: [DeviceController.turn_on_off] uses the same connection primitive (no behavior changes needed).
  6. Status: all tests pass locally.

@Minlor I have enhanced the feature. Please review it and let me know.Thankyou.

DhanashreePetare avatar Oct 18 '25 21:10 DhanashreePetare

Here's the code health analysis summary for commits c1c2ad0..b74bdad. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython❌ Failure
❗ 44 occurences introduced
🎯 22 occurences resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

deepsource-io[bot] avatar Oct 18 '25 21:10 deepsource-io[bot]

@Minlor I have implemented and corrected every bug. Every test I performed gave me 100% passed result locally. But these deepsource python issues kept on getting on every push. Can you please see into this once. If there is any solution to this, let me know, I will try my best to correct everything. Thankyou.

DhanashreePetare avatar Oct 19 '25 09:10 DhanashreePetare

I'm sorry for getting back to you so late, I'm sick at the moment so I'm just mostly trying to rest. Could you explain to me why the new on-off logic is argument based and within the menu which we have in the CLI? Also could you explain to me why the f-string were replaced with % formatting? 🤔

Minlor avatar Oct 20 '25 13:10 Minlor

  • [x] Why the on/off is a CLI argument ?

    I added --power on|off as a non‑interactive CLI mode so users and scripts can toggle device power quickly and safely without launching the interactive menu or GUI. The CLI path calls the new [power_on]/[power_off] helpers which manage their own socket lifecycle for simplicity and testability.

  • [x] Why f-strings were changed to %-format ?

  • I replaced f-strings in logging/error paths with logger-parameter or single-format usage to follow logging best practices (lazy formatting) and satisfy static checks.

  • Logging performance & best practice: for logger calls we use lazy formatting (e.g. [logger.info("Found %d devices", n)]) so the message isn’t interpolated unless the log level is enabled — this avoids wasted work and satisfies pylint’s W1203.

  • Reuse of one message: sometimes we build a single formatted [error_msg] (using %) so the exact same text can be both [print()]ed and [logger.error()]d without interpolating twice.

  • We kept simple f-strings where immediate interpolation is fine (e.g. plain prints); only logging or duplicated messages were changed.

  • [x] I validated the change with unit tests, import checks and CLI smoke tests so it’s non-invasive and safe.

This will not cause any harm to functionality but if there is a change needed, let me know.

DhanashreePetare avatar Oct 20 '25 15:10 DhanashreePetare

But this isn't meant to be ran as a script? and It should be within the CLI I don't see a reason as to why this would exist

Minlor avatar Oct 25 '25 23:10 Minlor