This is the same question as in Change keyboard locks in Python or How to change caps lock status without key press.
But there is a difference!!
I don't want to change the lights on /dev/console or /dev/tty but on a human interface device that is connected via USB and recognised as /dev/hidraw0.
To make it even harder, this is being used on a Raspberry Pi.
The method suggested in the other questions doesn't work.