kharyam/litra-driver

Get tools working on mac without sudo

bjcoombs opened this issue · 27 comments

Hi,

Firstly thanks for this. I was able to control my light via command line on mac, but it needs to run via sudo due to the usb libs used currently. I'm able to use the codes you've discovered to turn on/off the light via https://github.com/todbot/hidapitester.

Light On

hidapitester --vidpid 046D/C900 --open --length 20 --send-output 0x11,0xff,0x04,0x1c,0x01

Light Off

hidapitester --vidpid 046D/C900 --open --length 20 --send-output 0x11,0xff,0x04,0x1c

This works without sudo. As far as I can tell udev roles don't exists on mac.

I understand your project is written in python and the other referenced project is written in C. I wanted to post this question here incase anyone else found it helpful.

Thanks so much for the two commands! Those are already super useful as shell aliases. Can you share any others that you discover? Bright up/down especially.

I've managed to hack this library fairly simply to use hidapi on my Mac, without sudo, instead of pyusb. Would anyone be interested in that, and/or would @kharyam be interested in some sort of PR to add it to this project?

The need appears to stem from pyusb/pyusb#208. Unlike @bjcoombs, I wasn't able to get sudo to work on Monterey.

I’m interested- can you do a PR?

kjake commented

Would love this for macOS (Monterey). The G Hub app is slow, and I'd like to have some sort of key binding or at least alias to turn my light on/off instead of having to deal with the Logitech software - as good as it is.

I bodged these together into a working Mac solution - see https://ultracrepidarian.phfactor.net/2022/03/09/controlling-the-logitech-litra-on-macos/ for the writeup. Crude but all that I need.

kjake commented

Works wonderfully - thanks @phubbard! I used the Shortcuts setup to make the light turn off with ⌘F1 and on with ⌘F2

I love this @phubbard! Thank you. Honestly, this meets my needs since it's so low-level and simple(r) to edit/maintain, so unless I hear from @kharyam, I'll hold off on a PR for now.

I'm a bit late to the party here! @incanus if you're still interested in submitting a PR feel free and I will take a look and try to leverage your work.

Hello @phubbard @bjcoombs this is great, thank you. Can i use this on windows?
A first test have no effect.
.\hidapitester.exe --vidpid 046D/C900 --open --length 20 --send-output 0x11,0xff,0x04,0x1c,0x01 Opening device, vid/pid: 0x046D/0xC900 Writing output report of 20-bytes...wrote -1 bytes: 11 FF 04 1C 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Closing device
Thank for your feedback.

@SebaldJ - sorry, don't have a windows machine connected to the light to test. But perhaps you don't need this work around, have you tried the scripts found in this repo, rather than hidapitester?

Actually, second though, does hidapitester list the light as existing in your system. Try something like this:

hidapitester --list

does Logi - Litra Glow show up in the list of connected devices?

@bjcoombs yes, the device shows in the list, but without name:
046D/C900: -

@SebaldJ the command you pasted earlier is to turn the light on. Are you able to turn the light on by hand, and issue the second command to turn it off?

I'm not sure of the security implications of running this tool in windows, but perhaps it's not configured properly, for it not to get the full device names when issuing the list command, might flag that the device isn't responding back to the command line tool as expected. Do you have other devices with a full name in the list command?

@bjcoombs no effect, as administrator or not, and when i manual turned the device on, and run the command for off the light:

.\hidapitester.exe --vidpid 046D/C900 --open --length 20 --send-output 0x11,0xff,0x04,0x1c
Opening device, vid/pid: 0x046D/0xC900
Writing output report of 20-bytes...wrote -1 bytes:
 11 FF 04 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

Strange, then all other devices are listet with name.

056D/405F: EIZO corporation - EIZO USB HID Monitor
0B0E/245E: (null) - Jabra Link 370
0B0E/245E: (null) - Jabra Link 370
0B0E/245E: (null) - Jabra Link 370
04F3/0000: (null) - (null)
04F3/0000: (null) - (null)
04F3/0000: (null) - (null)
046D/C900:  -
046D/C52B: Logitech - USB Receiver
0B0E/245E: (null) - Jabra Link 370
046D/C900:  -
046D/C52B: Logitech - USB Receiver
046D/C232: (null) - (null)
04F3/2398: ELAN - Touchscreen
046D/C52B: Logitech - USB Receiver
04F3/2398: ELAN - Touchscreen
046D/C52B: Logitech - USB Receiver
04F3/2398: ELAN - Touchscreen
046D/C52B: Logitech - USB Receiver
04F3/2398: ELAN - Touchscreen
046D/C52B: Logitech - USB Receiver
046D/C52B: Logitech - USB Receiver
046D/085E: (null) - Logitech BRIO
046D/C52B: Logitech - USB Receiver
.\hidapitester.exe --vidpid 046D/C900 --list-detail
046D/C900:  -
  vendorId:      0x046D
  productId:     0xC900
  usagePage:     0x000C
  usage:         0x0001
  serial_number:
  interface:     -1
  path: \\?\hid#vid_046d&pid_c900&col01#8&11f83373&f&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

046D/C900:  -
  vendorId:      0x046D
  productId:     0xC900
  usagePage:     0xFF43
  usage:         0x0202
  serial_number:
  interface:     -1
  path: \\?\hid#vid_046d&pid_c900&col02#8&11f83373&f&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}

@SebaldJ, --usagePage ff43 should be added on Windows to properly drive the light as described on this post.
I wrote a Powershell script to drive the light on Windows: https://gist.github.com/gpailler/9e9725b022923ec69dfd8190da97236b

@gpailler thank you for the PS script, its works wonderfully under Windows 11. Thank you! 👍 😊
here my blog post https://www.dertechblog.de/2022/09/controlling-the-logitech-litra-on-windows/

How would I get to set a specific temperature here? I see @phubbard's list of commands (2700k, 3200k, and 6500k), but I'm unsure on how I would convert to the right input for something like for instance 3400k, or 4200k.

I wrote a python script to generate those. Let me look for it tonight, I don't have it on the work machine.

Is there a way to read settings? I'd love to create a little UI similar to https://github.com/kharyam/litra-driver

image

Thanks to @SebaldJ and the work done here by @kharyam, I was able to create a Python script and Alfred workflow for macOS (works with Intel and M1/M2) that uses @SebaldJ's path (a separate binary to do the USB comms, since pyusb has issues on macOS) -- thank you both!

It's here: https://github.com/darrenpmeyer/alfred-litra if you want to see what I did (python bit is in workflow/hid-litra.py

@statico does @darrenpmeyer's script work for you? If not, I can dig for my code or modify his to emit all of the color temp numbers. Honestly, his code is lovely, and if you can, just run his Python.

I got my lights (Litra Beam) today and wanted to be able to control them with my streamdeck on windows - here is a quick and dirty port to use the hidapi instead which seems to work well on Windows without the need to use zadig - and all my changes through the command line utility directly get picked up by the logitech software which continues to work. The same approach also works on OS X, just install hidapi with pip and you get control without sudo.

I did find the script. It’s a bit ugly, since I didn’t intend to reuse it. Let me clean up the output a bit - I assume what you need is the command string to create aliases for various color temps?

Hi, Paul. Thanks for getting back to me! Yes, that would be great. In the meantime, I was able to divine other color temperatures by adding 2 and 12 to the last two numbers, respectively, on the color temperature lines you had already listed in your script. I believe I found somewhere around 4K-5K with 18,92.

Here's the code (no dependencies - should run in any python3) and the results:

https://gist.github.com/phubbard/0046845978a2700650750b357bca0dc6

Here's the code (no dependencies - should run in any python3) and the results:

https://gist.github.com/phubbard/0046845978a2700650750b357bca0dc6

Thanks, Paul. This is exactly what I was looking for!

Just a heads up that I've released a go version of this application , a single native executable for the cli and ui. It uses hidapi so sudo is no longer needed. Let me know if you can give it a test!