logon84 / pySVS

Python3 app to control SVS SB-1000 PRO subwoofer settings using bluetooth
MIT License
9 stars 2 forks source link

Feature request > Keyboard shortcut(s) #4

Open stevland opened 1 year ago

stevland commented 1 year ago

Hi @logon84,

If you would consider adding keyboard shortcut support to this app (volume up/down is all I would personally need) then I would be able to pass those command(s) to my media center box from Home Assistant on all of my devices. And that would be sweet.

🙏

logon84 commented 1 year ago

I am outside of my city this week, so I cannot test. But doesn't TAB key switch from one element to others in the app? Once with focus on volume, if I remember right, using arrows will increase/decrease the value.

stevland commented 1 year ago

Thank you for the response.

Unfortunately, that isn't a beneficial solution.

To illustrate: I use a app called Voice Meeter (it allows me to use two sound cards independently). It accepts keyboard shortcuts for volume control.

While I'm watching a full screen movie on my media PC I can send those keyboard shortcuts to the PC through Unified Remote, Home Assistant, etc.

Thus I can increase or decrease the volume without pausing the movie (or resizing its window).

Using the TAB key (as you describe) assumes that pySVS is running in the foreground and that one is either physically controlling the PC, or is remotely controlling it. Either way the movie experience would be interrupted.

Let's say I'm watching Game of Thrones and there's a battle scene. It would be nice to be able to turn up the bass from my phone.

At this point, one might ask, why not just use the SVS app?

On Android the app is crap. Every time you open it, it crashes. So then you reopen it and then you have to wait 10 another seconds or so for it to reestablish its Bluetooth connection with the sub.

I assume pySVS would maintain a persistent connection with the sub.

If pySVS accepted keyboard shortcuts it could run continuously on the media PC and process commands on-the-fly. And I could control it through the same interface I already use to control media volume, balance, toggle subtitles on/ off, control the lighting in my house, the thermostat, yadda yadda yadda.

Screenshot_20231017_171443_Home Assistant

Even if SVS eventually get around to fixing their app... who needs it?!

Sorry for the verbose explanation / thanks for reading.

logon84 commented 1 year ago

This scenario is too specific for me to commit changes in pysvs just for this. But if I correctly understood what you want to achieve, probably is way easier for you to just use the command line mode, this way you can send commands to the sub in the background:

python3 pysvs.py -o -30

Run this and it will set volume on the sub to -30dB. If you want to increase or decrease by relative units, first ask the sub for the current volume:

python3 pysvs.py -o A

And then with basic output filtering you can achieve relative volume change.

stevland commented 1 year ago

It's true that I've presented a very niche scenario. Perhaps I went into too much detail about my specific objective. I would expect that keyboard shortcuts would benefit a lot of users / scenarios.

But command line mode may be a great solution for my needs, thanks for the suggestion.

I can't figure out how to determine the MAC address of my SVS PB-1000 Pro however. There's no MAC sticker on the back of the sub and the app offers no clue. What am I missing?!

stevland commented 1 year ago

I found the MAC address by using a third-party Bluetooth scanner.

I'm running W11 / Ubuntu (via Windows Subsystem for Linux)

stevland@Loves5:/mnt/c/pySVS-main$ ./pySVS.py -i
Traceback (most recent call last):
  File "/mnt/c/pySVS-main/./pySVS.py", line 145, in TX_thread
    async with BleakClient(address,adapter=dev) as client:
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/__init__.py", line 565, in __aenter__
    await self.connect()
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/__init__.py", line 605, in connect
    return await self._backend.connect(**kwargs)
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 129, in connect
    device = await BleakScanner.find_device_by_address(
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/__init__.py", line 385, in find_device_by_address
    return await cls.find_device_by_filter(
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/__init__.py", line 441, in find_device_by_filter
    async with cls(**kwargs) as scanner:
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/__init__.py", line 158, in __aenter__
    await self._backend.start()
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 168, in start
    manager = await get_global_bluez_manager()
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 1046, in get_global_bluez_manager
    await instance.async_init()
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 278, in async_init
    assert_reply(reply)
  File "/home/stevland/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.freedesktop.DBus.Error.TimedOut] Failed to activate service 'org.bluez': timed out (service_start_timeout=25000ms)
stevland commented 1 year ago

Yes, total newbie.

I subseqently realized that by "Windows" you probably mean installing Python in Windows.

So I've done that and installed bleak, pillow and requests.

When I try to run pySVS from Windows Command Prompt:

Traceback (most recent call last):
  File "C:\pySVS-main\pySVS.py", line 145, in TX_thread
    async with BleakClient(address,adapter=dev) as client:
  File "C:\Users\stevland\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\__init__.py", line 565, in __aenter__
    await self.connect()
  File "C:\Users\stevland\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\__init__.py", line 605, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\stevland\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\backends\winrt\client.py", line 287, in connect
    raise BleakDeviceNotFoundError(
bleak.exc.BleakDeviceNotFoundError: Device with address 08:EB:ED:62:DD:02 was not found.
stevland commented 1 year ago

OS Name Microsoft Windows 11 Pro Version 10.0.22621 Build 22621

Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32

Package                                                 Version
------------------------------------------------------- ---------
bleak                                                   0.21.1
certifi                                                 2023.7.22
charset-normalizer                                      3.3.0
idna                                                    3.4
Pillow                                                  10.1.0
pip                                                     23.3
requests                                                2.31.0
urllib3                                                 2.0.7
winrt-runtime                                           2.0.0b1
winrt-Windows.Devices.Bluetooth                         2.0.0b1
winrt-Windows.Devices.Bluetooth.Advertisement           2.0.0b1
winrt-Windows.Devices.Bluetooth.GenericAttributeProfile 2.0.0b1
winrt-Windows.Devices.Enumeration                       2.0.0b1
winrt-Windows.Foundation                                2.0.0b1
winrt-Windows.Foundation.Collections                    2.0.0b1
winrt-Windows.Storage.Streams                           2.0.0b1