Skip to content

Commit

Permalink
Network layout enhancements: added dead devices
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Jun 29, 2024
1 parent ca399ab commit c24da1c
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 51 deletions.
23 changes: 21 additions & 2 deletions core/ajax/Abeille.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ function pauseDaemons($stop = true, $dStatus = []) {

// Get equipments list
if (init('action') == 'getEqList') {
$gtwId = init('gtwId');
$gtwId = init('gtwId', 0); // Default == all networks

$status = 0;
$error = "";
Expand All @@ -671,6 +671,11 @@ function pauseDaemons($stop = true, $dStatus = []) {
foreach ($eqLogics as $eqLogic) {
$eqLogicId = $eqLogic->getLogicalId();
list($eqNet, $eqAddr) = explode("/", $eqLogicId);
if ($gtwId != 0) {
$i = substr($eqNet, 7); // AbeilleX => X
if ($i != $gtwId)
continue; // Not under the requested network
}

// Trying to identify zigbee device type
$zbType = "";
Expand All @@ -680,7 +685,7 @@ function pauseDaemons($stop = true, $dStatus = []) {
case 0: $zbType = "Coordinator"; break;
case 1: $zbType = "Router"; break;
case 2: $zbType = "End Device"; break;
default: $zbType = "?"; break;
default: break;
}
} else if (isset($zigbee['macCapa'])) {
$mc = hexdec($zigbee['macCapa']);
Expand All @@ -694,13 +699,27 @@ function pauseDaemons($stop = true, $dStatus = []) {
$zbType = "End Device";
}

$eqParent = $eqLogic->getObject();
if (!is_object($eqParent))
$objName = "";
else
$objName = $eqParent->getName();

$settings = $eqLogic->getConfiguration('ab::settings', []);

$eq = array(
'net' => $eqNet,
'addr' => $eqAddr,
'name' => $eqLogic->getName(),
'id' => $eqLogic->getId(),
'logicId' => $eqLogicId,
'objectName' => $objName,
'enabled' => $eqLogic->getIsEnable(),
'zbType' => $zbType,
'icon' => $eqLogic->getConfiguration('ab::icon', 'defaultUnknown'),
'x' => isset($settings['physLocationX']) ? $settings['physLocationX'] : 0,
'y' => isset($settings['physLocationY']) ? $settings['physLocationY'] : 0,
'z' => isset($settings['physLocationZ']) ? $settings['physLocationZ'] : 0, // Level
);
$eqList[$eqLogicId] = $eq;
}
Expand Down
3 changes: 0 additions & 3 deletions desktop/modal/AbeilleNetwork.modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ function displayNetworks($nbOfZigates, $what="linksTable", $mode="") {
.typeCoordinator-color {
color: #a65ba6;
}

.typeEndDevice-color {
color: #7BCC7B;
}

.typeRouter-color {
color: #00a2e8;
}

.typeUndefined-color {
color: #E5E500;
}
Expand Down
186 changes: 141 additions & 45 deletions desktop/php/AbeilleNetworkMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,24 @@
top: 60px;
left: 10px;
}
</style>
.typeCoordinator-color {
color: #a65ba6;
}
.typeEndDevice-color {
color: #7BCC7B;
}
.typeRouter-color {
color: #00a2e8;
}
.typeUndefined-color {
color: #E5E500;
}
</style>

<!-- <div class="row"> -->
<div class="ab-container">
<div class="ab-top">
Placement réseau (BETA, dev en cours)
Placement réseau
</div>
<div class="ab-bottom">
<div class="column ab-left-column">
Expand Down Expand Up @@ -185,7 +197,37 @@
</div>

</br>
</br>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th colspan="2">{{Légende}}</th>
</tr>
</thead>
<tbody>
<tr>
<td class="typeCoordinator-color" style="width: 30px"><i class="fas fa-square fa-2x"></i></td>
<td>{{Coordinateur}}</td>
</tr>
<tr>
<td class="typeRouter-color" style="width: 30px"><i class="fas fa-square fa-2x"></i></td>
<td>{{Routeur}}</td>
</tr>
<tr>
<td class="typeEndDevice-color" style="width: 30px"><i class="fas fa-square fa-2x"></i></td>
<td>{{Bout de chaine}}</td>
</tr>
<tr>
<td class="typeUndefined-color" style="width: 30px"><i class="fas fa-square fa-2x"></i></td>
<td>{{Type inconnu}}</td>
</tr>
<tr>
<td style="width: 30px"><img src="/plugins/Abeille/images/death.png" height="25px"></td>
<td>{{Sans vie}}</td>
</tr>
</tbody>
</table>

</br>
<button id="idConfigMode" style="width:100%;margin-top:4px;margin-right:7px">{{Mode config}}</button>
</br>
</br>
Expand Down Expand Up @@ -457,7 +499,7 @@ function checkPosLimits(devLogicId) {
if ((grpY + 50) > viewImageMaxY)
grpY = viewImageMaxY - 50;

console.log(" grpX="+grpX+", grpY="+grpY);
// console.log(" grpX="+grpX+", grpY="+grpY);
dev['posX'] = grpX + 25;
dev['posY'] = grpY + 25;
}
Expand Down Expand Up @@ -669,30 +711,6 @@ function endDrag(evt) {
}
}

// /* Draw 'legend' area */
// function drawLegend(includeGroup) {
// var legend = "";

// if ( includeGroup ) { legend = legend + '<g id="legend">'; }

// legend = legend + '<circle cx="100" cy="875" r="10" fill="red" />\n';
// legend = legend + '<a xlink:href="/index.php?v=d&m=Abeille&p=Abeille" target="_blank"> <text x="110" y="875" fill="black" style="font-size: 8px;">Coordinator</text> </a>\n';

// legend = legend + '<circle cx="100" cy="900" r="10" fill="blue" />\n';
// legend = legend + '<a xlink:href="/index.php?v=d&m=Abeille&p=Abeille" target="_blank"> <text x="110" y="900" fill="black" style="font-size: 8px;">Routeur</a>\n';

// legend = legend + '<circle cx="100" cy="925" r="10" fill="green" />\n';
// legend = legend + '<a xlink:href="/index.php?v=d&m=Abeille&p=Abeille" target="_blank"> <text x="110" y="925" fill="black" style="font-size: 8px;">End Equipment</text> </a>\n';

// legend = legend + '<circle cx="100" cy="950" r="10" fill="yellow" />\n';
// legend = legend + '<a xlink:href="/index.php?v=d&m=Abeille&p=Abeille" target="_blank"> <text x="110" y="950" fill="black" style="font-size: 8px;">Dans Jeedom mais pas dans l audit du reseau</text> </a>\n';

// if ( includeGroup ) { legend = legend + '</g>'; }

// return legend;
// }


// function selectSource(form) {
// Source = form.list.value;
// refreshAll();
Expand Down Expand Up @@ -852,17 +870,42 @@ function getLqiTables() {
}
}

// Retrieve list of devices registerd under Jeedom
// Note: BLOCKING function
function getJeedomDevices() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
jeedomDevices = JSON.parse(this.responseText);
console.log("jeedomDevices=", jeedomDevices);
}
};
// var xhr = new XMLHttpRequest();
// xhr.onreadystatechange = function() {
// if (this.readyState == 4 && this.status == 200) {
// jeedomDevices = JSON.parse(this.responseText);
// console.log("jeedomDevices=", jeedomDevices);
// }
// };
// xhr.open("GET", "/plugins/Abeille/core/php/AbeilleGetEq.php", false);
// xhr.send();

xhr.open("GET", "/plugins/Abeille/core/php/AbeilleGetEq.php", false);
xhr.send();
$.ajax({
type: 'POST',
url: "/plugins/Abeille/core/ajax/Abeille.ajax.php",
data: {
action: 'getEqList'
},
dataType: "json",
global: false,
cache: false,
async: false, // Blocking function
error: function (request, status, error) {
console.log("ERROR: Call to getEqList failed");
},
success: function (json_res) {
console.log("json_res=", json_res);
res = JSON.parse(json_res.result); // res.status, res.error, res.eqList
if (res.status != 0) {
} else {
jeedomDevices = res.eqList;
console.log("jeedomDevices=", jeedomDevices);
}
}
});
}

/* eqLogic/configuration settings (ab::settings) update */
Expand Down Expand Up @@ -917,6 +960,19 @@ function saveConfig() {
});
}

// Returns color according to Zigbee device type
function getDevColor(zbType) {
if (zbType == "Coordinator")
color = "#a65ba6";
else if (zbType == "Router")
color = "#00a2e8";
else if (zbType == "End Device")
color = "#7BCC7B";
else
color = "#E5E500";
return color;
}

// Combine LQI + Jeedom infos
function buildDevList() {
console.log("buildDevList()");
Expand All @@ -933,6 +989,8 @@ function buildDevList() {
netw.linksList = new Object();

lineId = 0; // To identify lines connecting nodes

// Listing devices on the network
for (rLogicId in netw.lqiTable.routers) {
router = netw.lqiTable.routers[rLogicId];
// console.log("router " + rLogicId + "=", router);
Expand All @@ -945,9 +1003,9 @@ function buildDevList() {
devR['name'] = router['name'];
devR['icon'] = router['icon'];
if (devR['addr'] == '0000')
devR['color'] = "Red"; // Coordinator
devR['color'] = getDevColor("Coordinator"); // Coordinator
else
devR['color'] = "Blue"; // Router
devR['color'] = getDevColor("Router"); // Router
if (typeof jeedomDevices[rLogicId] !== "undefined") {
devR['posX'] = jeedomDevices[rLogicId].x;
devR['posY'] = jeedomDevices[rLogicId].y;
Expand All @@ -961,6 +1019,9 @@ function buildDevList() {
netw.devListNb++;
}

if (typeof router['dead'] !== "undefined")
devR['dead'] = true;

for (nLogicId in router.neighbors) {
neighbor = router.neighbors[nLogicId];
// console.log("neighbor=", neighbor);
Expand All @@ -972,10 +1033,11 @@ function buildDevList() {
devN['addr'] = neighbor['addr'];
devN['name'] = neighbor['name'];
devN['icon'] = neighbor['icon'];
if ( neighbor['type'] == "End Device" ) { devN['color'] = "Green"; }
else if ( neighbor['type'] == "Router" ) { devN['color'] = "Blue"; }
else if ( neighbor['type'] == "Coordinator" ) { devN['color'] = "Red"; }
else devN['color'] = "Yellow";
// if ( neighbor['type'] == "End Device" ) { devN['color'] = zbEndDeviceColor; }
// else if ( neighbor['type'] == "Router" ) { devN['color'] = zbRouterColor; }
// else if ( neighbor['type'] == "Coordinator" ) { devN['color'] = zbCoordinatorColor; }
// else devN['color'] = "Yellow";
devN['color'] = getDevColor(neighbor['type'])
if (typeof jeedomDevices[nLogicId] !== "undefined") {
devN['posX'] = jeedomDevices[nLogicId].x;
devN['posY'] = jeedomDevices[nLogicId].y;
Expand All @@ -989,12 +1051,40 @@ function buildDevList() {
netw.devListNb++;
} // End for (nLogicId in router.neighbors)

if (typeof neighbor['dead'] !== "undefined")
devN['dead'] = true;

devN['links'][lineId] = rLogicId;
devR['links'][lineId] = nLogicId;
netw.linksList[lineId] = { 'src': rLogicId, 'dst': nLogicId, 'lqi': neighbor['lqi'] };
lineId++;
}
} // End 'for (rLogicId in lqiTable.routers)'

// Checking devices in Jeedom but not visible on the network
for (jLogicId in jeedomDevices) {
jDev = jeedomDevices[jLogicId];
if (jDev.enabled == 0)
continue; // Disabled => ignoring
if (typeof netw.devList[jLogicId] !== "undefined")
continue; // Already in the list

// Adding dead device
devJ = new Object();
devJ['addr'] = jDev.addr;
devJ['name'] = jDev.name;
devJ['icon'] = jDev.icon;
devJ['color'] = getDevColor(jDev.zbType);
devJ['posX'] = jDev.x;
devJ['posY'] = jDev.y;
devJ['posZ'] = jDev.z;
devJ['jeedomId'] = jDev.id;
devJ['dead'] = true;

netw.devList[jLogicId] = devJ;
netw.devListNb++;
}

console.log("Net "+n+" devList=", netw.devList);
}
}
Expand Down Expand Up @@ -1083,7 +1173,7 @@ function setAutoY(isZigate) {
function drawDevice(devLogicId) {
console.log("drawDevice("+devLogicId+")");
dev = devList[devLogicId];
// console.log("dev=", dev);
console.log("dev=", dev);

nodeColor = dev['color'];
addr = dev['addr'];
Expand Down Expand Up @@ -1138,6 +1228,12 @@ function drawDevice(devLogicId) {
// newG += '<a xlink:href="/index.php?v=d&m=Abeille&p=Abeille&id='+dev['jeedomId']+'" target="_blank"><text x="'+txtX+'" y="'+txtY+'" fill="black" style="font-size: 12px;">'+dev['name']+'</text></a>';
// newG += '</g>';

if (typeof dev['dead'] !== 'undefined') {
deadX = 32;
deadY = 28;
newG += '<image xlink:href="/plugins/Abeille/images/death.png" x="'+deadX+'" y="'+deadY+'" height="20" />';
}

// newG += '<g id="'+devLogicId+'-txt" transform="translate('+txtX+', '+txtY+')">';
// newG += '<a xlink:href="/index.php?v=d&m=Abeille&p=Abeille&id='+dev['jeedomId']+'" target="_blank"><text x="'+txtX+'" y="'+txtY+'" fill="black" style="font-size: 12px;">'+dev['name']+'</text></a>';
newG += '<a xlink:href="/index.php?v=d&m=Abeille&p=Abeille&id='+dev['jeedomId']+'" target="_blank"><text fill="black" style="font-size: 12px;">'+dev['name']+'</text></a>';
Expand All @@ -1155,7 +1251,7 @@ function drawDevice(devLogicId) {
}
newG += '</g>';

// console.log("newG=", newG);
console.log("newG=", newG);

return newG;
}
Expand Down
7 changes: 6 additions & 1 deletion docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
- Améliorations: Analyse réseau: Indique si le routeur ne répond pas. Affichage par une tête de mort.
- Améliorations: Page EQ/avancé: Support extended pour 'getIeeeAddress'.
- Interne: Support 'Mgmt_ieee_req/rsp' pour type 'extended'.
- Améliorations: Graphique des liens. Affiche les équipements connus d'Abeille mais pas dans le réseau Zigbee (ou sans vie).
- Améliorations graphique des liens: Affiche les équipements connus d'Abeille mais pas dans le réseau Zigbee (ou sans vie).
- Améliorations placement réseau
- Alignement des couleurs avec 'Graphique des liens'.
- Ajout légende.
- Ajout des équipements connus de Jeedom mais plus visibles sur le réseau (sans vie).
- Ajout tête de mort sur équipement sans vie.

## 240624-BETA-1

Expand Down

0 comments on commit c24da1c

Please sign in to comment.