Hello
As promise a solution to get eufy security level working with domiticz
Ok,
First you need to have pip and python (3.7 on my side) installed
As you know, Eufy does not provide any API. So some people have investigate the system and provided some scripts in Python to dos some actions on Eufy System (on Eufy Doorbell but some are reusable on EufyCam)
More precisely, the system state (HOME, AWAY, DISARMED) is activated by a P2P connexion ! So it is not possible to activate a state by an API call.
Luckily we have a GIT with a solution. You need to anderstand that you have to install a first GIT and to override some script but files from another GIT
There are 4 steps :
Step 1/ using pi user (not root user) : Get the python eufy security library and example from the git :
you can download it using wget using this link
https://github.com/keshavdv/python-eufy ... ve/p2p.zip
Step 2/ Install the non P2P version by pip3 utility :
sudo pip3 install python-eufy-security
sudo pip3 install -r requirements_test.txt
Step 3/Replace some file by P2P file (here i have used my pi user in step 1) :
3.1/ in directory /home/pi/.local/lib/python3.7/site-packages/
rename eufy_security to eufy_security.OLD
cp -R /path_to_eufy_p2pofstep1/eufy_security /home/pi/.local/lib/python3.7/site-packages/
3.2/ ** USING ROOT USER ** in directory /usr/local/lib/python3.7/dist-packages
rename eufy_security to eufy_security.OLD
cp -R /path_to_eufy_p2pofstep1/eufy_security /usr/local/lib/python3.7/dist-packages
4/ My 3 scripts in python to change mode in Eufy Security :
********ARMED AWAY************
Code: Select all
import asyncio
import logging
import os
from aiohttp import ClientSession
from eufy_security import async_login
from eufy_security.types import GuardMode
logging.basicConfig(level=logging.ERROR)
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
EUFY_EMAIL = "your_email_eufy"
EUFY_PASSWORD = "your_password"
async def main() -> None:
"""Create the aiohttp session and run the example."""
async with ClientSession() as websession:
# Create an API client:
api = await async_login(EUFY_EMAIL, EUFY_PASSWORD, websession)
for station in api.stations.values():
print("--ARMEMENT DE LA MAISON : PASSAGE EN MODE ABSENT--")
print(f"Station Name: {station.name}")
print(f"Serial Number: {station.serial}")
# print(f"Station params: {station.params}")
print(f"Station type: {station.device_type}")
async with station.connect() as session:
await station.set_guard_mode(GuardMode.AWAY, session)
await asyncio.sleep(10)
asyncio.get_event_loop().run_until_complete(main())
********ARMED HOME************
Code: Select all
import asyncio
import logging
import os
from aiohttp import ClientSession
from eufy_security import async_login
from eufy_security.types import GuardMode
logging.basicConfig(level=logging.ERROR)
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
EUFY_EMAIL = "your_email_eufy"
EUFY_PASSWORD = "your_password"
async def main() -> None:
"""Create the aiohttp session and run the example."""
async with ClientSession() as websession:
# Create an API client:
api = await async_login(EUFY_EMAIL, EUFY_PASSWORD, websession)
for station in api.stations.values():
print("--ARMEMENT DE LA MAISON : PASSAGE EN MODE ABSENT--")
print(f"Station Name: {station.name}")
print(f"Serial Number: {station.serial}")
# print(f"Station params: {station.params}")
print(f"Station type: {station.device_type}")
async with station.connect() as session:
await station.set_guard_mode(GuardMode.HOME, session)
await asyncio.sleep(10)
asyncio.get_event_loop().run_until_complete(main())
********DISARMED************
Code: Select all
import asyncio
import logging
import os
from aiohttp import ClientSession
from eufy_security import async_login
from eufy_security.types import GuardMode
logging.basicConfig(level=logging.ERROR)
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
EUFY_EMAIL = "your_email_eufy"
EUFY_PASSWORD = "your_password"
async def main() -> None:
"""Create the aiohttp session and run the example."""
async with ClientSession() as websession:
# Create an API client:
api = await async_login(EUFY_EMAIL, EUFY_PASSWORD, websession)
for station in api.stations.values():
print("--ARMEMENT DE LA MAISON : PASSAGE EN MODE ABSENT--")
print(f"Station Name: {station.name}")
print(f"Serial Number: {station.serial}")
# print(f"Station params: {station.params}")
print(f"Station type: {station.device_type}")
async with station.connect() as session:
await station.set_guard_mode(GuardMode.DISARMED, session)
await asyncio.sleep(10)
asyncio.get_event_loop().run_until_complete(main())
**********That's all****
If your scripts are running to can see that the state in Eufy App is correctly changing when you start a script
After that you have to call them by DZVENTS on trigger using a bash script call the python script (dzvents->bash->python). Let me know if you succeded in interact your eufycam
Please note that the current python eufy security seems to be incompatible with my script (may be they run with an old version of the library), another user of the forum use this script (to adapt for each state) and is ok :
Code: Select all
import asyncio
import logging
import os
from aiohttp import ClientSession
from eufy_security import async_login
from eufy_security.types import GuardMode
logging.basicConfig(level=logging.DEBUG)
EUFY_EMAIL = ""
EUFY_PASSWORD = ""
async def main() -> None:
"""Create the aiohttp session and run the example."""
async with ClientSession() as websession:
# Create an API client:
api = await async_login(EUFY_EMAIL, EUFY_PASSWORD, websession)
for station in api.stations.values():
print("------------------")
print(f"Station Name: {station.name}")
print(f"Serial Number: {station.serial}")
print(f"Station params: {station.params}")
print(f"Station type: {station.device_type}")
async with station.connect() as session:
await station.set_guard_mode(GuardMode.AWAY, session)
await asyncio.sleep(10)
asyncio.get_event_loop().run_until_complete(main())
Here you have my sh scripts that call pyhton and is call by dzvents :
Code: Select all
/usr/bin/python3.7 /home/pi/domoticz/scripts/personnels/eufy_armedaway.py &
Here you have mu dzvents scripts for armed away :
Code: Select all
-- Debug
local LOGGING = true
-- TELEGRAM settings
telegram_token = "****"
telegram_chatid = 00000
local t_actif = true
--Others settings
local version = 'EUFY on ArmedAway v0.0.1 du 2020/07'
--EMOJI
local emoji_CocheVerte = '\xE2\x9C\x85'
local emoji_PointExclamationRouge = '\xE2\x9D\x97'
local emoji_CroixRouge = '\xE2\x9D\x8C'
local emoji_Warning = '\xE2\x9A\xA0'
function telegram_EUFY_on_armedaway(message)
if (t_actif) then
os.execute('curl --data chat_id='..telegram_chatid..' --data-urlencode "text='..message..'" "https://api.telegram.org/bot'..telegram ... endMessage" ')
end
end
function isempty(s)
return s == nil or s == ''
end
function round(num, dec)
if num == 0 then
return 0
else
local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult
end
end
return {
active = true,
--on = {['timer'] = {'every minute'}},
on = {security = { domoticz.SECURITY_ARMEDAWAY }},
execute = function(domoticz, item)
-- message pour telegram
local msg = domoticz.time.rawTime..'\n\r'..version..'\n\r\n\r'
if (LOGGING) then
print("Armement de la maison : Activation du mode ABSENT de EufySecurity")
end
--cmd='/usr/bin/python3.7 /home/pi/domoticz/scripts/personnels/eufy_armedaway.py'
--utilisation d'un shell avec l'execution en backgroud pour eviter de bloquer domoticz le temps de l'execution
cmd='/home/pi/domoticz/scripts/personnels/eufy_armedaway.sh'
--local f = assert(io.popen(cmd, 'r'))
--s = assert(f:read('*a'))
--f:close()
--print(s)
os.execute(cmd)
msg=msg..'Armement de la maison : Activation du mode ABSENT de EufySecurity'
telegram_EUFY_on_armedaway(msg)
end
}
Have fun