Hello,
I'm not sure if I'm posting in the right place, but I'm attempting to make a skin that allows me to control some TP-Link KL130 lights via the python-kasa library.
I really do not know anything about Python coding, but I am able to send commands through python-kasa and control the lights via command line.
What I'm asking is, what sort of code do I need to execute this following a button press?
For example, in command line I would do this from the python scripts directory in my AppData folder:
.\kasa --type bulb --host 192.168.1.XXX hsv 30 80 10
That would turn the bulb to 10% brightness at a given hue and saturation level.
I know I need to use the LeftMouseUpAction command, I'm just not sure exactly how to format the file path.
Hopefully this makes sense. Any help would be appreciated
Thanks,
Cody
It is currently October 3rd, 2024, 11:07 pm
Button to Execute a Command Line Command through a Python Script
-
- Posts: 2
- Joined: May 25th, 2023, 6:22 pm
-
- Rainmeter Sage
- Posts: 8324
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Button to Execute a Command Line Command through a Python Script
Assuming your AppData folder is the folder that most users have it in "C:\Users\[UserName]\AppData\Roaming" and your python scripts directory in a subfolder in called "Python" there, and you have, let's say, a text file called "file.txt" in that location, adding to your meter something like:kokinda.cody wrote: ↑May 25th, 2023, 6:30 pm Hello,
I'm not sure if I'm posting in the right place, but I'm attempting to make a skin that allows me to control some TP-Link KL130 lights via the python-kasa library.
I really do not know anything about Python coding, but I am able to send commands through python-kasa and control the lights via command line.
What I'm asking is, what sort of code do I need to execute this following a button press?
For example, in command line I would do this from the python scripts directory in my AppData folder:
.\kasa --type bulb --host 192.168.1.XXX hsv 30 80 10
That would turn the bulb to 10% brightness at a given hue and saturation level.
I know I need to use the LeftMouseUpAction command, I'm just not sure exactly how to format the file path.
Hopefully this makes sense. Any help would be appreciated
Thanks,
Cody
Code: Select all
LeftMouseUpAction=["%APPDATA%\Python\file.txt"]
Code: Select all
LeftMouseUpAction=["%APPDATA%\Python\kasa --type bulb --host 192.168.1.XXX hsv 30 80 10"]
Code: Select all
LeftMouseUpAction=["%APPDATA%\Python\kasa" "--type bulb --host 192.168.1.XXX hsv 30 80 10"]
It's best to try first with something simple, say a batch file with a parameter, to make sure it works, before you apply it to your actual case, just to be sure you don't change some things (i.e. whatever "kasa" controls) unintentionally in the testing phase.
-
- Posts: 2
- Joined: May 25th, 2023, 6:22 pm
Re: Button to Execute a Command Line Command through a Python Script
Thanks for the response. I wasn't able to get that working quite like what you had written, but I did manage to get it working in a roundabout way.
I ended up doing a VBS script that loads a batch file without a console window popping up.
This was the code I used in my skin:
LeftMouseUpAction=["%AppData%\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\100.vbs]
Seems to be working for now, and I'll probably end up having that batch file run at startup to turn the lights on, with the Rainmeter skin allowing me to change the brightness of the lights when I need to during the day.
Thanks for the guidance!
I ended up doing a VBS script that loads a batch file without a console window popping up.
This was the code I used in my skin:
LeftMouseUpAction=["%AppData%\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\100.vbs]
Seems to be working for now, and I'll probably end up having that batch file run at startup to turn the lights on, with the Rainmeter skin allowing me to change the brightness of the lights when I need to during the day.
Thanks for the guidance!
-
- Rainmeter Sage
- Posts: 8324
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Button to Execute a Command Line Command through a Python Script
Ah, I see. If you want to run a command line without showing the console screen, take a look at the Documentation / Manual / Plugins / RunCommand from the main Rainmeter webpage. A RunCommand measure can Hide the command window and even get its output as a string, if you want to use it further. It's easy to use, just look at the examples on that page. I'm on mobile now, so I can't provide a code ATM.kokinda.cody wrote: ↑May 26th, 2023, 12:57 am Thanks for the response. I wasn't able to get that working quite like what you had written, but I did manage to get it working in a roundabout way.
I ended up doing a VBS script that loads a batch file without a console window popping up.
This was the code I used in my skin:
LeftMouseUpAction=["%AppData%\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\100.vbs]
Seems to be working for now, and I'll probably end up having that batch file run at startup to turn the lights on, with the Rainmeter skin allowing me to change the brightness of the lights when I need to during the day.
Thanks for the guidance!