Closed FlyingDiver closed 3 years ago
I think this is the relevant part of dmesg on the pi:
[ 3.363464] usb 1-1.2: new full-speed USB device number 4 using dwc_otg
[ 3.505152] usb 1-1.2: New USB device found, idVendor=1a86, idProduct=e024, bcdDevice= 1.0c
[ 3.521457] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3.545855] hid-generic 0003:1A86:E024.0001: hiddev96,hidraw0: USB HID v1.00 Device [HID 1a86:e024] on usb-20980000.usb-1.2/input0
MacOSX does not have hidraw support so it'll wont work there.
For raspbian if you run dmesg | grep hidraw
are there any lines that show up after?
pi@raspberrypi:~/WyzeSensePy $ dmesg | grep hidraw
[ 1.023076] hidraw: raw HID events driver (C) Jiri Kosina
[ 3.545855] hid-generic 0003:1A86:E024.0001: hiddev96,hidraw0: USB HID v1.00 Device [HID 1a86:e024] on usb-20980000.usb-1.2/input0
That's incredibly weird. Is there an orange and white flashing light on the usb dongle?
Orange light, not flashing.
This part is straight out of the starter kit. It's never been attached to a Wyze camera.
Ah okay. I think what's happening is that sample.py is failing with that error message on any IOError. I've seen some people report that you need elevated privs to access hidraw devices on raspbian. Try with sudo?
Ah. That worked.
pi@raspberrypi:~/WyzeSensePy $ sudo python3 sample.py --device /dev/hidraw0
Openning wyzesense gateway ['/dev/hidraw0']
Gateway info:
MAC:7781E59E
VER:0.0.0.30 V1.4 Dongle UD3U
ENR:b'1546866884c76deae03f2fc3bf2c3976'
L to list
P to pair
U to unpair
X to exit
Action:
If you don't want to run with sudo you can also create / Modify the file /etc/udev/rules.d/99-com.rules on your machine and insert KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="pi"
I think your user will belong to the pi group by default.
I changed the permissions in /dev/hidraw0 and then it worked without sudo. But that's temporary. I will try the other solution.
Ah gotcha. Yeah not sure if that works if its remounted but I've seen a couple people use the other method with success after restarts.
Does the rPi reboot if you unplug and replug the device? Seems strange.
OK, the restart set the permissions correctly per the instructions above, and the sample code works without the sudo.
Now I need to see what it's going to take to get a hidraw (or equivalent) driver on MacOSX. The goal is to make the sensors available to a Home Automation system.
Pretty sure the pi shouldnt restart when you unplug the dongle. Though if you unplug it and plug it back in the hidraw number might change.
I think thats not gonna be easy. I think apple locks it down at the kernel level and only provides access through their api's. If your end goal is to integrate with a HA system take a look at these projects based on this:
https://github.com/kevinvincent/ha-wyzesense https://github.com/dariopb/ha-gosenseapp
I think you'll particularly be interested in the second one for your use case, (if your main HA stuff is on mac).
If I wanted to run it connected to an rPi, I'd be done already. ;). But in the end, that might be the only solution.
On the other hand, I could possibly write an IOKit driver to talk to the Wyze, then just do my normal Python thing. Working on it...
I've tried running this code on two systems. On MacOS X (latest) there's no /dev/hidraw device, and I couldn't find a driver for that available anywhere.
On raspbian, there IS a /dev/hidraw0, but I get:
What system are you testing this code on, and did you have to install any drivers to make it work? Documenting this in the README or somewhere would be very useful.