Python Forum
Sending string commands from Python to a bluetooth device
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending string commands from Python to a bluetooth device
#13
(Aug-31-2021, 05:43 PM)deanhystad Wrote: Instead of a list I would use a dictionary that maps button labels to commands.
commands = {
    'TV Standby':'standby',
    ...
    'Air Conditioning On': 'ac on',
    'Air Conditioning Off': 'ac off'
}
btn_titles = list(command.keys())
Then use the dictionary to get the command.
    def button_clicked(self, idx, title):
        command = commands[title]
        # send command

Hi, thank you for your comment. Can you please show me how to attach these parts in to the code ? And I should use import bluetooth right ?
Reply


Messages In This Thread
RE: Sending string commands from Python to a bluetooth device - by Rovelin - Aug-31-2021, 06:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending a text from Python sawtooth500 2 335 Apr-14-2024, 01:56 PM
Last Post: sawtooth500
  Read data via bluetooth frohr 9 3,732 Jul-10-2022, 09:51 AM
Last Post: frohr
  Connect to HC-05 Bluetooth (NOT BLE) korenron 0 1,552 Jun-26-2022, 09:06 AM
Last Post: korenron
  Read buffer from bluetooth frohr 2 2,256 Jun-01-2022, 01:31 PM
Last Post: frohr
  Scan for Bluetooth device korenron 0 2,737 Jan-10-2022, 01:06 PM
Last Post: korenron
  ModuleNotFoundError: No module named 'bluetooth' Error Rovelin 4 12,480 Aug-31-2021, 04:04 PM
Last Post: Rovelin
  Python library for win32 console commands eldiener 3 3,615 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 2,076 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  Possible to execute a python script before log off/shutdown with input commands? Kaltex 1 2,340 May-18-2021, 06:31 AM
Last Post: Skaperen
  Bluetooth send message after connecting? korenron 2 2,744 Apr-26-2021, 05:50 AM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020