Petit mode opératoire de ce qui fonctionne chez moi depuis env 10 jours
Attention, je précise que tout a été codé avec ClaudeIA, je ne pourrai donc pas expliquer davantage ce contenu 
Voir également si ça fonctionne avec toutes les caméras Ezviz. Perso j’ai des H8C filaire et CB8 solaire
Création d’un répertoire : script/EZVIZ/
Création d’un Fichier config.py
EZVIZ_EMAIL = "identifiant"
EZVIZ_PASSWORD = "mdp"
EZVIZ_REGION = "eu"
CAMERAS = {
"Camera 1" : "BGxxxx",
"Camera 2" : " BGxxxx ",
"Camera 3" : " BGxxxx",
“Camera 4" : "BGxxxx",
}
Création d’un Fichier activation.py
#!/usr/bin/env python3
import sys
import logging
import getpass
from pyezviz import EzvizClient
from config import EZVIZ_EMAIL, EZVIZ_PASSWORD, EZVIZ_REGION, CAMERAS
LOG_FILE = f"/tmp/ezviz_activation_{getpass.getuser()}.log"
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
handlers=[
logging.FileHandler(LOG_FILE),
logging.StreamHandler(sys.stdout)
]
)
logger = logging.getLogger(__name__)
mode = sys.argv[1] if len(sys.argv) > 1 else "on"
noms_cibles = sys.argv[2:] if len(sys.argv) > 2 else []
logger.info(f"Démarrage — mode={mode}, cibles={noms_cibles if noms_cibles else 'toutes'}")
try:
client = EzvizClient(EZVIZ_EMAIL, EZVIZ_PASSWORD, EZVIZ_REGION)
client.login()
logger.info("Connexion Ezviz réussie")
for nom, serial in CAMERAS.items():
if not noms_cibles or nom in noms_cibles:
client.set_camera_defence(serial, 1 if mode == "on" else 0)
logger.info(f"Caméra {nom} ({serial}) → détection {'activée' if mode == 'on' else 'désactivée'}")
else:
logger.debug(f"Caméra {nom} ({serial}) → ignorée")
client.close_session()
logger.info("Session fermée — script terminé avec succès")
except Exception as e:
logger.error(f"Erreur : {e}", exc_info=True)
sys.exit(1)
Création d’un Fichier intrusion.py
#!/usr/bin/env python3
import sys
import json
import logging
import getpass
from pyezviz import EzvizClient
from config import EZVIZ_EMAIL, EZVIZ_PASSWORD, EZVIZ_REGION, CAMERAS
LOG_FILE = f"/tmp/ezviz_intrusion_{getpass.getuser()}.log"
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
handlers=[
logging.FileHandler(LOG_FILE),
logging.StreamHandler(sys.stderr)
]
)
logger = logging.getLogger(__name__)
# Patch BatteryCameraWorkMode
import pyezviz.constants as _c
if not any(m.value == 7 for m in _c.BatteryCameraWorkMode):
_c.BatteryCameraWorkMode._value2member_map_[7] = list(_c.BatteryCameraWorkMode)[0]
noms_cibles = sys.argv[1:] if len(sys.argv) > 1 else []
resultats = {}
try:
client = EzvizClient(EZVIZ_EMAIL, EZVIZ_PASSWORD, EZVIZ_REGION)
client.login()
cameras_data = client.load_cameras()
for nom, serial in CAMERAS.items():
if noms_cibles and nom not in noms_cibles:
continue
cam = cameras_data.get(serial)
if cam is None:
resultats[nom] = {"erreur": "introuvable", "serial": serial}
continue
resultats[nom] = {
"serial": serial,
"motion_detectee": cam.get("Motion_Trigger", False),
"secondes_depuis_trig": cam.get("Seconds_Last_Trigger"),
"pir_status": cam.get("PIR_Status", 0),
"derniere_alarme": cam.get("last_alarm_time"),
"type_alarme_code": cam.get("last_alarm_type_code"),
"type_alarme_nom": cam.get("last_alarm_type_name"),
"derniere_alarme_img": cam.get("last_alarm_pic"),
"notif_alarme": cam.get("alarm_notify", False),
"batterie": cam.get("battery_level"),
"statut": cam.get("status"),
}
client.close_session()
print(json.dumps(resultats, ensure_ascii=False, indent=2))
except Exception as e:
logger.error(f"Erreur : {e}", exc_info=True)
print(json.dumps({"erreur": str(e)}, ensure_ascii=False))
sys.exit(1)
Pour chaque caméra, il faut faire une commande qui génère un fichier xxx.sh (j’avoue que je n’ai pas tout compris)
Il y a aussi des pbs de droits d’écriture/lecture, etc
----- demandez à votre ami ClaudeIA -----
- Alarme >> date/ heure détection
- Batterie >> niveau de batterie (sauf filaire)
- Motion >> 0 ou 1 en cas de détection
- Type >> détection voiture ou humain
Exemple

#!/bin/bash
/usr/bin/python3 /var/www/html/script/EZVIZ/intrusion.py 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(int(d.get('Portail', {}).get('motion_detectee', False)))"
Utilisation Activation/Désactivation
Mise à jour des commandes avec le plugin script
Auto-actualisation : * * * * *
Exemple
Différents scénarios qui se lancent en fonction d’évènements souhaités
Exemple : activation caméra sud
Exemple : désactivation caméra sud
Utilisation Intrusion
Exemple d’utilisation : détection humain ou voiture ET mode absent
Déclencheur scénario : #[PILOTAGE GLOBAL][Intrusion Camera][Motion Portail]# == 1
Allumage lumières extérieures, envoie mail, fermeture volets, etc