No that didn't work either. When the error occurs the device is listed as unconnected even when it is physically connected (the multiple copies of the same device in the list comes from it having been plugged into different USB hub ports)
Edit: tried devcon again just now and solved it by making a .bat file that disables+enables the whole class of devices:
devcon disable =HIDClass
devcon enable =HIDClass
When the error occurs I just use FARR to run the .bat file
Edit2: The above worked for the mouse but also had the drawback of messing with the multimedia keys of my keyboard (until the next restart). That is caused by the .bat file disabling/enabling too many devices. So I made a new attempt at disabling/enabling only the specific mouse device. It now works when I specify it like this:
devcon disable *PID_XYZ*
devcon enable *PID_XYZ*
where XYZ is replaced with data for the specific device (as shown in the properties > information tab for the device in Device Manager). It remains to see if that value can change, but it works so far.
Edit3: Yes, it definitely works. I think the problem with my first attempt was to specify the complete string ID string from the device properties (including the backslashes). The shorter command with wildcards above did the trick.
Ideally I'd like to automate this even more so that a script runs on each boot and checks the mouse device status. When the mouse was not responding then the device properties had a special flag (I think it had problem or error in the name but don't remember exactly). But I can't find a way to check for that flag through devcon. So for the moment I'll just run the above script on each reboot.