Page 1 of 3

EufyCam E : set security mode fom domoticz

Posted: Friday 03 July 2020 12:15
by multinet
Hello

Eufycam is a good solution for home camera (quality / price / no monthly fee etc) BUT Anker/Eufy does NOT provide an api to control security mode or stream flow

After multiple try I succeed in switching security mode of myc eufy homebase directly from domoticz (disarmed; away ; home)
This has been able using the gret work from some guys and shared on github

I don't know if it is used by many people here but I can describe "how-to" even if i'm french :)

Multinet

Re: EufyCam E : set security mode fom domoticz

Posted: Wednesday 08 July 2020 10:24
by meel4chris
Hi,

Great to hear you have integrated eufy with domoticz! I’m considering to buy the eufy 2 to integrate it with my alarm in domoticz.
Is it possible to control a switch in domoticz from eufy?
For example, when eufy detects a movement a switch is triggered in domoticz?

Greeting,
Christian


Verzonden vanaf mijn iPhone met Tapatalk

Re: EufyCam E : set security mode fom domoticz

Posted: Thursday 09 July 2020 16:44
by lost
meel4chris wrote: Wednesday 08 July 2020 10:24 Great to hear you have integrated eufy with domoticz! I’m considering to buy the eufy 2 to integrate it with my alarm in domoticz.
Is it possible to control a switch in domoticz from eufy?
For example, when eufy detects a movement a switch is triggered in domoticz?
The cam should be able to send a http command using domoticz JSON API directly... I doubt this is the case. If some FTP setup can be done, you may code a service monitoring FTP on server side (device hosting Domoticz) with short time slices (10s with 3 cams and much more post treatment than described here can be done on a PI3). Pictures present: Store/send them elsewhere and trigger a virtual PIR in Domoticz for instance.

Anyway, why bother with a device that claims to integrate IA capabilities and is only able to do face detection ; just as any basic camera does for focus since more that 10 years: I may be wrong as I don't own this brand (no closed/cloud based devices in my home as a rule of thumb) but no need for IA for such basic function!

Other brands allow this and are not closed products: I have some Dahua references that integrate face detection, on top of usual motion (but much more configurable than many other brands), as well as other advanced features like line crossing (less sensible to artefacts than motion, if the area to monitor allows this: Simple geometry + distance before/after line setup, otherwise this may not be reliable)... 2MPix branded "startlight" devices also have a very good night sensitivity and from aliexpress they usually ship for 40/45€ depending on discounts and €/$ rates.

Re: EufyCam E : set security mode fom domoticz

Posted: Friday 10 July 2020 17:11
by meel4chris
Hi,
thanks for your input. I'm quite new into the camera's so I appreciate every tip!
I checked the Dahua cameras but couldnt find the face recognization. I like to be able to trigger different actions based on who's approaching.
For example I checked the camera below.
https://www.ipcam-shop.nl/ipc-g26ep.htm ... nal_tabbed
Where is the AI done? in the camera or are you using additional software / hardware?

Re: EufyCam E : set security mode fom domoticz

Posted: Saturday 18 July 2020 21:38
by lost
meel4chris wrote: Friday 10 July 2020 17:11 I checked the Dahua cameras but couldnt find the face recognization. I like to be able to trigger different actions based on who's approaching.
For example I checked the camera below.
https://www.ipcam-shop.nl/ipc-g26ep.htm ... nal_tabbed
Where is the AI done? in the camera or are you using additional software / hardware?
For the Dahuas I own, this is face identification (no AI needed), not recognition. But this is enough to maximize chances to have someone that may be identified (with a nice face snapshot!) if needed.

Eufycam does not look to provide recognition as well and cloud shit looks needed, thus not a good deal IMO.

Re: EufyCam E : set security mode fom domoticz

Posted: Friday 21 August 2020 21:21
by tomson
I would be very interested to understand how you have been able to set the security move in Eufy from Domoticz. A small howto would be really appreciated.

Re: EufyCam E : set security mode fom domoticz

Posted: Monday 24 August 2020 16:56
by multinet
tomson wrote: Friday 21 August 2020 21:21 I would be very interested to understand how you have been able to set the security move in Eufy from Domoticz. A small howto would be really appreciated.
I’m back

I will post a detailed solution here next days

We are to be aware using git, python, bash and dzvents.

Multinet

Re: EufyCam E : set security mode fom domoticz

Posted: Monday 24 August 2020 17:21
by tomson
Thnx. I am looking forward to it.

Re: EufyCam E : set security mode fom domoticz

Posted: Thursday 27 August 2020 19:48
by multinet
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

Re: EufyCam E : set security mode fom domoticz

Posted: Monday 07 September 2020 22:13
by tomson
Thanks for sharing this. I took me a bit longer than expected, because I needed to upgrade my whole PI and Domoticz. I needed to do that for a long time already, so thanks for the push :D

The howto worked for me. Thanks! I am now able to arm my Eufy security from Domoticz.

The only step I didn't need to take is to copy eufy-security to /home/pi/.local/lib/python3.7/site-packages/. I don't have anything python related in my local lib folder.

Re: EufyCam E : set security mode fom domoticz

Posted: Tuesday 08 September 2020 10:33
by multinet
Hello

Great news

Too bad that eufy/année does not provide an API like all others competitors.

Thanks to all guys that put public a solution for us ;)

Have a good day
Multinet

Re: EufyCam E : set security mode fom domoticz

Posted: Wednesday 30 September 2020 11:02
by diskhub
multinet wrote: Thursday 27 August 2020 19:48

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())

I am trying to run the above piece of code in local machine and it always cannot connect.
It fails at
EufySecurityP2PError(f"Could not connect to {self.name}")
eufy_security.errors.EufySecurityP2PError: Could not connect to eufy HomeBase2

in particular it fails in this function in station.py:

Code: Select all

   async def connect(self, addr: str = None):
        dsk_key_resp = await self._api.request(
            "post", "app/equipment/get_dsk_keys", json={"station_sns": [self.serial]}
        )
        for item in dsk_key_resp.get("data")["dsk_keys"]:
            if item["station_sn"] == self.serial:
                p2p_session = P2PSession(
                    self.serial,
                    self.station_info["p2p_did"],
                    item["dsk_key"],
                    self.station_info["member"]["action_user_id"],
                )
                is_connected = await p2p_session.connect(addr)
                if is_connected:
                    try:
                        yield p2p_session
                    finally:
                        await p2p_session.close()
                    return
                else:
                    raise EufySecurityP2PError(f"Could not connect to {self.name}")
        else:
            raise EufySecurityP2PError(f"Could not find discovery key for {self.name}")

Any reason that you can think of? It also get False in the is_connected.
Despite i explicitly assign station.station_info["ip_addr"] to the addr, it still cannot connect.

Did I do anything wrong?

Re: EufyCam E : set security mode fom domoticz

Posted: Wednesday 30 September 2020 12:17
by diskhub
Ok. It's because i am behind VPN. it's solved now.
The code works perfectly

Re: EufyCam E : set security mode fom domoticz

Posted: Wednesday 30 September 2020 12:26
by diskhub
What's the enum value for the GeoFencing guard mode?

Re: EufyCam E : set security mode fom domoticz

Posted: Saturday 10 October 2020 14:27
by Benoit50
Great, it works perfectly with Jeedom.
Thanks for the solution

Re: EufyCam E : set security mode fom domoticz

Posted: Saturday 10 October 2020 15:19
by multinet
diskhub wrote: Wednesday 30 September 2020 12:26 What's the enum value for the GeoFencing guard mode?
No but if you found it please share it

Re: EufyCam E : set security mode fom domoticz

Posted: Tuesday 17 November 2020 16:42
by wishmaster84
This is awesome! I was totally bumped out that Eufy doesn't have an API.
This let's me create (working) Geofencing AND scheduling.

Great work and thanks for sharing.

By the way if someone would like to enable the schedule. The value is exactly that. So: Guardmode.SCHEDULE

Re: EufyCam E : set security mode fom domoticz

Posted: Wednesday 18 November 2020 12:33
by multinet
I agree that it is totally weird not to provide an API !

Re: EufyCam E : set security mode fom domoticz

Posted: Saturday 23 January 2021 12:49
by Alain
We just installed a Eufy system with four homebases, four camera's and a multitude of door sensors and motion detectors. Shame Eufy doesn't support interconnecting of homebases. I hope to at least be able to switch modes on two homebases at once with a single Domoticz switch command.

I'll be starting this project probably next week.

Re: EufyCam E : set security mode fom domoticz

Posted: Tuesday 26 January 2021 20:09
by wishmaster84
Hi All,

Starting today my scripts suddenly stopped working when running them.
Anybody else having this problem?