Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map test #2240

Merged
merged 19 commits into from
Oct 17, 2024
Merged
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ You can thank the authors by these links:
-----------------------------------------------------------------------------------------------------
## Changelog

### UNRELEASED
### ### 1.10.10 (2024-09-27)
* (lebrinkma) fix linter errors
* (asgothian) disable map display for deactivated devices
* (asgothian) new option on map: disable physics interaction
* (asgothian) new zigbee-herdsman-converters 20.28.0
* (asgothian) new zigbee-herdsman 2.1.1
* (asgothian) Allow use of keyless converters (used for TuYa and compatible devices in zigbee-herdsman-converters
* (arteck) swap from request to axios

### 1.10.9 (2024-09-05)
* (arteck) typo admin settings
Expand Down
37 changes: 22 additions & 15 deletions admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ let devices = [],
shuffleInstance;
const updateCardInterval = setInterval(updateCardTimer, 6000);

const networkOptions = {
autoResize: true,
height: '100%',
width: '100%',
nodes: {
shape: 'box'
},
layout: {
improvedLayout: true,
},
physics: {
enabled: true,
}
};


const savedSettings = [
'port', 'panID', 'channel', 'disableLed', 'countDown', 'groups', 'extPanID', 'precfgkey', 'transmitPower',
'adapterType', 'debugHerdsman', 'disableBackup', 'disablePing', 'external', 'startWithInconsistent', 'warnOnDeviceAnnouncement', 'baudRate', 'flowCTRL'
Expand Down Expand Up @@ -1099,13 +1115,13 @@ function showNetworkMap(devices, map) {
const edges = [];

if (map.lqis == undefined || map.lqis.length === 0) { // first init
$('#filterParent, #filterSibl, #filterPrvChild, #filterMesh').change(function () {
$('#filterParent, #filterSibl, #filterPrvChild, #filterMesh, #physicsOn').change(function () {
updateMapFilter();
});
}

const createNode = function (dev, mapEntry) {
if (dev.common && dev.common.type == 'group') return undefined;
if (dev.common && (dev.common.type == 'group' || dev.common.deactivated)) return undefined;
const extInfo = (mapEntry && mapEntry.networkAddress) ? `\n (nwkAddr: 0x${mapEntry.networkAddress.toString(16)} | ${mapEntry.networkAddress})` : '';
const node = {
id: dev._id,
Expand Down Expand Up @@ -1296,19 +1312,8 @@ function showNetworkMap(devices, map) {
nodes: nodesArray,
edges: mapEdges
};
const options = {
autoResize: true,
height: '100%',
width: '100%',
nodes: {
shape: 'box'
},
layout: {
improvedLayout: true,
}
};

network = new vis.Network(container, data, options);

network = new vis.Network(container, data, networkOptions);

const onMapSelect = function (event) {
// workaround for https://github.com/almende/vis/issues/4112
Expand Down Expand Up @@ -1406,6 +1411,8 @@ function updateMapFilter() {
const showSibl = $('#filterSibl').is(':checked');
const showPrvChild = $('#filterPrvChild').is(':checked');
const invisColor = $('#filterMesh').is(':checked') ? 0.2 : 0;
networkOptions.physics.enabled = $('#physicsOn').is(':checked');
network.setOptions(networkOptions);
mapEdges.forEach((edge) => {
if (((edge.relationship === 0 || edge.relationship === 1) && showParent)
|| (edge.relationship === 2 && showSibl)
Expand Down
6 changes: 6 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,12 @@ <h3 class="translate">Map view config</h3>
<span style="pointer-events: none;">Mesh</span>
</label>
</div>
<div id="physicsOnTgl" class="input-field col s12 admin-tooltip-icon translateT"
title="Physics On">
<label for="physicsOn" style="pointer-events: auto;">
<input style="pointer-events: none;" id="physicsOn" type="checkbox" class="filled-in"checked="checked"/> <span style="pointer-events: none;">Physics</span>
</label>
</div>
</div>
<div class="input-field input-group col s12 m6 l6">
<p class="translate">Device map info</p>
Expand Down
8 changes: 7 additions & 1 deletion admin/tab_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,13 @@ <h3 class="translate">Map view config</h3>
<span style="pointer-events: none;">Mesh</span>
</label>
</div>
</div>
<div id="physicsOnTgl" class="input-field col s12 admin-tooltip-icon translateT"
title="Physics On">
<label for="physicsOn" style="pointer-events: auto;">
<input style="pointer-events: none;" id="physicsOn" type="checkbox" class="filled-in"checked="checked"/> <span style="pointer-events: none;">Physics</span>
</label>
</div>
</div>
<div class="input-field input-group col s12 m6 l6">
<p class="translate">Device map info</p>
</div>
Expand Down
15 changes: 14 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"common": {
"name": "zigbee",
"version": "1.10.9",
"version": "1.10.10",
"news": {
"1.10.10": {
"en": "core update\ndependency update",
"de": "kern-update\naktualisierung der abhängigkeit",
"ru": "обновление\nобновление",
"pt": "atualização do núcleo\natualização de dependência",
"nl": "kernupdate\nafhankelijkheidsupdate",
"fr": "mise à jour de base\nmise à jour de la dépendance",
"it": "aggiornamento del core\naggiornamento della dipendenza",
"es": "actualización básica\nactualización de la dependencia",
"pl": "podstawowa aktualizacja\naktualizacja zależności",
"uk": "оновлення ядра\nоновлення залежності",
"zh-cn": "核心更新\n依赖性更新"
},
"1.10.9": {
"en": "typo admin settings\neslint config",
"de": "typo admin einstellungen\neslint config",
Expand Down
42 changes: 35 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,18 @@
this.log.debug(`entity: ${deviceId} ${model} ${safeJsonStringify(entity)}`);

const mappedModel = entity.mapped;

if (!mappedModel) {
this.log.debug(`No mapped model for ${model}`);
return;
}

if (!mappedModel.toZigbee)
{
this.log.error(`No toZigbee in mapped model for ${model}`);
return;
}

stateList.forEach(async changedState => {
const stateDesc = changedState.stateDesc;
const value = changedState.value;
Expand Down Expand Up @@ -691,13 +697,35 @@
}
return;
}
const converter = mappedModel.toZigbee.find(c => c && (c.key.includes(stateDesc.prop) || c.key.includes(stateDesc.setattr) || c.key.includes(stateDesc.id)));
if (!converter) {
this.log.error(`No converter available for '${model}' with key '${stateDesc.id}' `);
this.sendError(`No converter available for '${model}' with key '${stateDesc.id}' `);
return;
}

let converter = undefined;
for (const c of mappedModel.toZigbee) {

if (!c.hasOwnProperty('convertSet')) continue;
this.log.debug(`Type of toZigbee is '${typeof c}', Contains key ${(c.hasOwnProperty('key')?JSON.stringify(c.key):'false ')}`)

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (91% of all statements in
the enclosing function
have an explicit semicolon).
if (!c.hasOwnProperty('key') && c.hasOwnProperty('convertSet') && converter === undefined)
{
converter = c;
this.log.debug('setting converter to keyless converter')

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (91% of all statements in
the enclosing function
have an explicit semicolon).
continue;
}
if (c.key.includes(stateDesc.prop) || c.key.includes(stateDesc.setattr) || c.key.includes(stateDesc.id))
{
this.log.debug(`${(converter===undefined?'Setting':'Overriding')}' converter to converter with key(s)'${JSON.stringify(c.key)}}`)

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (91% of all statements in
the enclosing function
have an explicit semicolon).
converter = c;
}

}
/*
if (!mappedModel.toZigbee[0].hasOwnProperty('key') && mappedModel.toZigbee[0].hasOwnProperty('convertSet')) converter = mappedModel.toZigbee[0];
converter = mappedModel.toZigbee.find(c => c && c.hasOwnProperty('key') && (c.key.includes(stateDesc.prop) || c.key.includes(stateDesc.setattr) || c.key.includes(stateDesc.id)));
*/
if (converter === undefined) {
this.log.error(`No converter available for '${model}' with key '${stateDesc.id}' `);
this.sendError(`No converter available for '${model}' with key '${stateDesc.id}' `);
return;
}

const preparedValue = (stateDesc.setter) ? stateDesc.setter(value, options) : value;
const preparedOptions = (stateDesc.setterOpt) ? stateDesc.setterOpt(value, options) : {};

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.zigbee",
"version": "1.10.9",
"version": "1.10.10",
"author": {
"name": "Kirov Ilya",
"email": "[email protected]"
Expand Down Expand Up @@ -28,8 +28,8 @@
"ajv": "^8.17.1",
"uri-js": "^4.4.1",
"typescript": "^5.6.2",
"zigbee-herdsman": "0.56.2",
"zigbee-herdsman-converters": "20.2.0"
"zigbee-herdsman": "2.1.1",
"zigbee-herdsman-converters": "20.28.0"
},
"description": "Zigbee devices",
"devDependencies": {
Expand Down
Loading