J’ai modifié 2 fichiers
dahuavto.class.php
vers la ligne 217 j’ai ajouté ci dessous pour créer des commandes
$doorstatus = $this->getCmd(null, 'doorstatus');
if (!is_object($doorstatus)) {
$doorstatus = new dahuavtoCmd();
$doorstatus->setName(__('Contact Porte', FILE));
}
$doorstatus->setLogicalId('doorstatus');
$doorstatus->setEqLogic_id($this->getId());
$doorstatus->setType('info');
$doorstatus->setSubType('other');
$unlock->setTemplate('dashboard','light');
$unlock->setTemplate('mobile','light');
$doorstatus->save();
$doorstatus = $this->getCmd(null, 'CardNo');
if (!is_object($doorstatus)) {
$doorstatus = new dahuavtoCmd();
$doorstatus->setName(__('Num Badge', FILE));
}
$doorstatus->setLogicalId('CardNo');
$doorstatus->setEqLogic_id($this->getId());
$doorstatus->setType('info');
$doorstatus->setSubType('other');
$unlock->setTemplate('dashboard','light');
$unlock->setTemplate('mobile','light');
$doorstatus->save();
$doorstatus = $this->getCmd(null, 'CardType');
if (!is_object($doorstatus)) {
$doorstatus = new dahuavtoCmd();
$doorstatus->setName(__('Type Badge', FILE));
}
$doorstatus->setLogicalId('CardType');
$doorstatus->setEqLogic_id($this->getId());
$doorstatus->setType('info');
$doorstatus->setSubType('other');
$unlock->setTemplate('dashboard','light');
$unlock->setTemplate('mobile','light');
$doorstatus->save();
daemon.py
ligne 74 j’ai rjouté la notion de CardNo mais aussi le retour de commande de porte
if message.get("Action") == "Pulse" and message.get("Code") == "AccessControl" and messageData.get("Status") == 1:
# "Index" is 0 or 1
# 'unlocked' command is 1 or 2
commandName = 'unlocked2' if message["Index"] == 1 else 'unlocked1'
self._send_change({ commandName: 1 })
Timer(
10,
lambda: self._send_change({ commandName: 0 }),
).start()
if message.get("Action") == "Pulse" and message.get("Code") == "DoorStatus" and messageData.get("Status") == "Open":
self._send_change({ 'doorstatus': 1 }),
if message.get("Action") == "Pulse" and message.get("Code") == "DoorStatus" and messageData.get("Status") == "Close":
self._send_change({ 'doorstatus': 0 }),
if message.get("Action") == "Pulse" and message.get("Code") == "AccessControl" and messageData.get("CardNo") != "":
self._send_change({ 'CardNo': messageData.get("CardNo") })
Timer(
30,
lambda: self._send_change({ 'CardNo': 0 }),
).start()
