python-eufy-security
python-eufy-security copied to clipboard
MQTT Integration
I have limited resources right now. It would be awesome if someone integrates that package though: https://github.com/nonsleepr/python-eufy-security-mqtt
I’ll have mine installed this weekend. I can test if you still need it.
I would love to test this but I am having some trouble in running the example. I changed the variables in subscribe.py and when I run it I get this:
python3 subscribe.py
Traceback (most recent call last):
File "subscribe.py", line 2, in <module>
from eufy_security.mqtt import DoorbellEvents
ModuleNotFoundError: No module named 'eufy_security'
What do I need to do before I can run the example?
@joepadmiraal You need to pip install .
first.
Thanks.
When I run it now I get this error:
Connection rejected with code '5'
Connection failed: ConnectException('Connection rejected by broker')
I got the userId by reading from the passport/login
API call.
For email I used the same email address that I used in the app.
I red android_id by going into the adb shell of the emulator and running settings get secure android_id
I also changed the url to security-mqtt-eu.eufylife.com:8789
in the init file because I am based in the Netherlands.
But that gave the same results.
Googling code 5 seems to reveal it is an authentication issue. Any idea what I could try next?
Thanks
Try running the following script (requires mosquitto-clients
installed, you can get eufy.crt
from the package):
#! /usr/bin/env bash
set -x
device_sn=T8200N0XXXXXXXXX
[email protected]
# adb shell settings get secure android_id
android_id=deadc0dedeadc0de
username=eufy_$user_id
password=$email
client=android_EufySecurity_${user_id}_${android_id}
mosquitto_sub \
--cafile eufy.crt \
-C 1 -F '%p' -N \
-h security-mqtt.eufylife.com \
-p 8789 \
-t "/phone/doorbell/$device_sn/push_message" \
-u "$username" -P "$password" -i "$client"
I ran this (replaced some details with X):
set -x
user_id=cc05d0a796a1877a352e7ee80XXXXXXXXXXXX
device_sn=T8010PXXXXXXXXXX
[email protected]
android_id=f404f4XXXXXXXXXX
username=eufy_$user_id
password=$email
client=android_EufySecurity_${user_id}_${android_id}
mosquitto_sub \
--cafile eufy.crt \
-C 1 -F '%p' -N \
-h security-mqtt.eufylife.com \
-p 8789 \
-t "/phone/doorbell/$device_sn/push_message" \
-u "$username" -P "$password" -i "$client"
Result:
mosquitto_sub --cafile eufy.crt -C 1 -F %p -N -h security-mqtt.eufylife.com -p 8789 -t /phone/doorbell/T8010PXXXXXXXXX/push_message -u eufy_cc05d0a796a1877a352e7ee80XXXXXXXXX -P [email protected] -i android_EufySecurity_cc05d0a796a1877a352e7ee80XXXXXXXXX_f404f4XXXXXXXXX
Connection error: Connection Refused: not authorised.
After it did not work I replaced the android_id with one from a real device which also has the app installed. That gave the exact same result. Also replaced the host with security-mqtt-eu.eufylife.com.
Is it correct that the email address is used as password?
Yes, that's how it's implemented in the Android app. Have you tried another host (security-mqtt-eu.eufylife.com
) here too?
@joepadmiraal Haven't tried to MitM, however, the code in the repo and the script works for me with wired doorbell and in the US though (used my primary account).
I can run your case under debugger if you create a disposable account for me (can email it to me) and aren't concerned about the privacy implications that much.
On Wed, Jun 3, 2020, 1:56 PM joepadmiraal [email protected] wrote:
Yes already tried security-mqtt-eu.eufylife.com. I have been using the main account to test. Did you also do this or did you use a dedicated guest account? Did you ever manage to do a mitm with mqtt on the eufy device?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FuzzyMistborn/python-eufy-security/issues/43#issuecomment-638362840, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR2WQW2TS6M3P3RAMP4GYTRU2FERANCNFSM4NMM2IGA .
I figured out I mixed up two accounts. So now it is not giving me any errors when I start the script. However it also does not show any events at all.
I'll create a temp account and email it to you.
@joepadmiraal
How did you execute the passport/login API to get the userid?
I changed api.py
so it reads and exposes auth_resp["data"]["user_id"]
.
With that I could let test_api.py
print the userId.
@joepadmiraal @nonsleepr
Thank you for the info on finding the user_id. Needed to modify the api.py in my usr/bin/lib directory.
With the above script, are you doing this to acquire a new eufy.crt that is associated to your eufy doorbell?
If I create an executable script with my user_id, serial_number and email addy I get an error that the the file cannot be found.
If I copy the file eufy.crt from the src folder to my getcert.sh location then I get "connection refused not authorized."
What am I potentially doing wrong?
getcert.sh
set -x user_id=955b3b9241fa76f2559ece18247XXXXXXXXXXXXX
device_sn=T8200N00XXXXXXXX email=aXXXXXXXXXXXXXXXXXXXX.cc android_id=deadc0dedeadc0de
username=eufy_$user_id password=$email client=android_EufySecurity_${user_id}_${android_id}
mosquitto_sub
--cafile eufy.crt
-C 1 -F '%p' -N
-h security-mqtt.eufylife.com
-p 8789
-t "/phone/doorbell/$device_sn/push_message"
-u "$username" -P "$password" -i "$client"
It's possible that the wireless version of the doorbell relies on the FCM path like the floodlight rather than MQTT, in which case, I don't think would show any events. I can confirm the MQTT integration did work for me with a wired doorbell so it's still probably worthwhile to integrate for at least that set of users to be able to get realtime motion events for HA.
@keshavdv i have the wired doorbell and cannot connect to the Mqtt service. Can you provide guidance?
@joepadmiraal @nonsleepr With the above script, are you doing this to acquire a new eufy.crt that is associated to your eufy doorbell?
I deleted the certificate and ran make
in the repository directory to create a new certificate.
I don't know if that is actually needed.
If I copy the file eufy.crt from the src folder to my getcert.sh location then I get "connection refused not authorized."
What am I potentially doing wrong?
I rechecked it today and I am now also getting errors again when using the eu servers.
With the standard security-mqtt.eufylife.com
server from the script it does not give a authorization error.
Now that I think of it, another reason for why I don't get any MQTT messages could also be because I have a European model instead of a US model.
i can sub to "#" on security-mqtt-eu.eufylife.com - (i'm having a homebase with 4 eufycams 2 and 2c, no doorbell).
Like joe i'm not getting any messages either. Not sure what to expect actually :)
Hello all
Thank you for all the code you provide !
After installing dependencies I can run a python3.7 python-eufy-security-p2p/examples/test_api.py with error (some information hidded but ):
pi@domoticz:~/domoticz/scripts/personnels/python-eufy-security-p2p/examples $ python3.7 test_api.py
DEBUG:asyncio:Using selector: EpollSelector
INFO:eufy_security.api:Switching to another API_BASE: https://security-app-eu.eufylife.com/v1
INFO:root:------------------
INFO:root:Camera Name: Allée
INFO:root:Serial Number: T811******************
INFO:root:Station Serial Number: T800****************
INFO:root:Last Camera Image URL: https://zhixin-security-eu.s3.eu-central-1.amazonaws.com/thumb/2020/07/01/station/T8002H********************************
INFO:root:Enabling OSD
Traceback (most recent call last):
File "test_api.py", line 62, in
But most important for my : this problem
when I try to run a python3.7 python-eufy-security-p2p/examples/test_p2p.py I got an error :
pi@domoticz:~/domoticz/scripts/personnels/python-eufy-security-p2p/examples $ python3.7 ./test_p2p.py
Traceback (most recent call last):
File "./test_p2p.py", line 8, in
Do you know how I can fix that problem ? Thanks to @joepadmiraal @nonsleepr if they can have a look at my post ;)
For sure i've done previously a pip3 install python_eufy_security with succes: pi@domoticz:~/domoticz/scripts/personnels/python-eufy-security-p2p/examples $ pip3 install python-eufy-security Requirement already satisfied: python-eufy-security in /home/pi/.local/lib/python3.7/site-packages (0.3.1) Requirement already satisfied: aiohttp==3.6.1 in /home/pi/.local/lib/python3.7/site-packages (from python-eufy-security) (3.6.1) Requirement already satisfied: chardet<4.0,>=2.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp==3.6.1->python-eufy-security) (3.0.4) Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp==3.6.1->python-eufy-security) (19.3.0) Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp==3.6.1->python-eufy-security) (1.4.2) Requirement already satisfied: multidict<5.0,>=4.5 in /usr/local/lib/python3.7/dist-packages (from aiohttp==3.6.1->python-eufy-security) (4.7.6) Requirement already satisfied: async-timeout<4.0,>=3.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp==3.6.1->python-eufy-security) (3.0.1) Requirement already satisfied: idna>=2.0 in /usr/local/lib/python3.7/dist-packages (from yarl<2.0,>=1.0->aiohttp==3.6.1->python-eufy-security) (2.10)
Are there any updates related to this? MQTT for the doorbell would be amazing!
IIUC MQTT only works with wired doorbell (T8200).