From 4fa204589b07b06ed3dce246f99c5bc4d2e4516c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Fri, 2 Aug 2024 08:59:33 +0200
Subject: [PATCH 01/11] Create z2m.js
---
mobile/js/z2m.js | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
create mode 100644 mobile/js/z2m.js
diff --git a/mobile/js/z2m.js b/mobile/js/z2m.js
new file mode 100644
index 00000000..c01c5f39
--- /dev/null
+++ b/mobile/js/z2m.js
@@ -0,0 +1,73 @@
+"use strict"
+
+$('body').attr('data-page', 'z2m')
+
+$('#searchContainer').hide()
+
+var $bottompanel_routerlist
+
+function initz2mpromptRouter() {
+ $bottompanel_routerlist = $('#changeIncludeStateEnable')
+ $bottompanel_routerlist.empty()
+ $bottompanel_routerlist.append(' Tout')
+ $bottompanel_routerlist.append(' Coordinateur')
+ for(var i in z2m_devices){
+ if(z2m_devices[i].isgroup == 1 || z2m_devices[i].isChild == 1 || z2m_devices[i].device_type != 'Router'){
+ continue;
+ }
+ $bottompanel_routerlist.append(' ' + z2m_devices[i].HumanName + '')
+ }
+ $bottompanel_routerlist.append('
')
+
+ $bottompanel_routerlist = $('#changeIncludeStateDisable')
+ $bottompanel_routerlist.empty()
+ $bottompanel_routerlist.append(' Tout')
+ $bottompanel_routerlist.append(' Coordinateur')
+ for(var i in z2m_devices){
+ if(z2m_devices[i].isgroup == 1 || z2m_devices[i].isChild == 1 || z2m_devices[i].device_type != 'Router'){
+ continue;
+ }
+ $bottompanel_routerlist.append(' ' + z2m_devices[i].HumanName + '')
+ }
+ $bottompanel_routerlist.append('
')
+}
+
+$('#changeIncludeStateEnable').off('click', '.routers').on('click', '.routers', function(e) {
+ jeedom.z2m.bridge.include({
+ id: $(this).attr('data-id'),
+ mode : 1,
+ error: function(error) {
+ $('#div_alert').showAlert({message: error.message, level: 'danger'})
+ },
+ success: function() {
+ $('#div_alert').showAlert({message: '{{Lancement du mode inclusion}}', level: 'success'})
+ $('#changeIncludeStateEnable').hide()
+ }
+ })
+})
+
+$('#changeIncludeStateDisable').off('click', '.routers').on('click', '.routers', function(e) {
+ jeedom.z2m.bridge.include({
+ id: $(this).attr('data-id'),
+ mode : 0,
+ error: function(error) {
+ $('#div_alert').showAlert({message: error.message, level: 'danger'})
+ },
+ success: function() {
+ $('#div_alert').showAlert({message: '{{Désactivation du mode inclusion}}', level: 'success'})
+ $('#changeIncludeStateDisable').hide()
+ }
+ })
+ })
+
+$('body').off('z2m::includeDevice').on('z2m::includeDevice', function(_event, _options) {
+if (modifyWithoutSave) {
+ $('#div_alert').showAlert({
+ message: '{{Un périphérique vient d\'être inclu/exclu. Veuillez réactualiser la page}}',
+ level: 'warning'
+ });
+} else if (_options != '') {
+ window.location.href = 'index.php?v=d&p=z2m&m=z2m&id=' + _options;
+}
+})
+initz2mpromptRouter();
From 358c59895fb87676858d338f4fd00c51f3409a47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Fri, 2 Aug 2024 09:01:17 +0200
Subject: [PATCH 02/11] Create z2m.html
---
mobile/html/z2m.html | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 mobile/html/z2m.html
diff --git a/mobile/html/z2m.html b/mobile/html/z2m.html
new file mode 100644
index 00000000..07230f6b
--- /dev/null
+++ b/mobile/html/z2m.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
From 6faa2a47be30c6474ef80879e009eade8bcc3f93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Fri, 2 Aug 2024 09:01:45 +0200
Subject: [PATCH 03/11] Create z2m.php
---
mobile/html/z2m.php | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 mobile/html/z2m.php
diff --git a/mobile/html/z2m.php b/mobile/html/z2m.php
new file mode 100644
index 00000000..0f381d87
--- /dev/null
+++ b/mobile/html/z2m.php
@@ -0,0 +1,36 @@
+getId());
+$eqLogics = eqLogic::byType($plugin->getId());
+
+foreach ($eqLogics as $eqLogic) {
+ $devices[$eqLogic->getLogicalId()] = array(
+ 'HumanNameFull' => $eqLogic->getHumanName(true),
+ 'HumanName' => $eqLogic->getHumanName(),
+ 'id' => $eqLogic->getId(),
+ 'img' => $eqLogic->getImgFilePath(),
+ 'device_type' => $eqLogic->getConfiguration('device_type','EndDevice'),
+ 'isgroup' => $eqLogic->getConfiguration('isgroup', 0),
+ 'isChild' => $eqLogic->getConfiguration('isChild', 0),
+ 'ieee' => z2m::convert_from_addr(explode('|', $eqLogic->getLogicalId())[0])
+ );
+ $deviceAttr[$eqLogic->getId()] = array(
+ 'isgroup' => $eqLogic->getConfiguration('isgroup', 0),
+ 'multipleEndpoints' => $eqLogic->getConfiguration('multipleEndpoints', 0),
+ 'isChild' => $eqLogic->getConfiguration('isChild', 0)
+ );
+}
+$devices[0] = array('HumanNameFull' => 'Contrôleur', 'HumanName' => 'Contrôleur', 'id' => 0, 'img' => 'plugins/z2m/core/config/devices/coordinator.png');
+sendVarToJS('z2m_devices', $devices);
+sendVarToJS('devices_attr', $deviceAttr);
+$bridge_infos = z2m::getDeviceInfo('bridge1');
+if($bridge_infos['permit_join'] && isset($bridge_infos['permit_join_timeout'])){
+ event::add('jeedom::alert', array(
+ 'level' => 'success',
+ 'page' => 'z2m',
+ 'message' => __('Mode inclusion actif', __FILE__),
+ 'ttl' => $bridge_infos['permit_join_timeout'] * 1000
+ ));
+}
+?>
From 8133a29f31f2f6507671ecf43a5d47ce55355904 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Mon, 7 Apr 2025 12:57:50 +0200
Subject: [PATCH 04/11] Update post-install.sh
pnpm@10.4.1
---
resources/post-install.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/post-install.sh b/resources/post-install.sh
index 6a1169b9..aeed2ba8 100644
--- a/resources/post-install.sh
+++ b/resources/post-install.sh
@@ -41,7 +41,7 @@ if [ -n "${wanted_z2m_version}" ] && [ $(echo $wanted_z2m_version | head -c 1) -
npm ci
npm run build
else
- npm install -g pnpm
+ npm install -g pnpm@10.4.1
pnpm i --frozen-lockfile
pnpm run build
fi
From 9aa929e04eba449259edb75da5e716a6d966f589 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Mon, 7 Apr 2025 13:49:44 +0200
Subject: [PATCH 05/11] Update z2m.php
fixed timeout relative calculation
---
desktop/php/z2m.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/desktop/php/z2m.php b/desktop/php/z2m.php
index 24bc9461..362f1053 100644
--- a/desktop/php/z2m.php
+++ b/desktop/php/z2m.php
@@ -28,12 +28,12 @@
sendVarToJS('z2m_devices', $devices);
sendVarToJS('devices_attr', $deviceAttr);
$bridge_infos = z2m::getDeviceInfo('bridge1');
-if($bridge_infos['permit_join'] && isset($bridge_infos['permit_join_timeout'])){
+if($bridge_infos['permit_join'] && isset($bridge_infos['permit_join_end'])){
event::add('jeedom::alert', array(
'level' => 'success',
'page' => 'z2m',
'message' => __('Mode inclusion actif', __FILE__),
- 'ttl' => $bridge_infos['permit_join_timeout'] * 1000
+ 'ttl' => $bridge_infos['permit_join_end'] - time() * 1000
));
}
?>
From 4f59d0e489eaed1f789671abafd7fa6e9bae8d6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Mon, 7 Apr 2025 14:04:06 +0200
Subject: [PATCH 06/11] Update z2m.php
fixed timeout relative calculation
---
mobile/html/z2m.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mobile/html/z2m.php b/mobile/html/z2m.php
index 0f381d87..f57d8963 100644
--- a/mobile/html/z2m.php
+++ b/mobile/html/z2m.php
@@ -25,12 +25,12 @@
sendVarToJS('z2m_devices', $devices);
sendVarToJS('devices_attr', $deviceAttr);
$bridge_infos = z2m::getDeviceInfo('bridge1');
-if($bridge_infos['permit_join'] && isset($bridge_infos['permit_join_timeout'])){
+if($bridge_infos['permit_join'] && isset($bridge_infos['permit_join_end'])){
event::add('jeedom::alert', array(
'level' => 'success',
'page' => 'z2m',
'message' => __('Mode inclusion actif', __FILE__),
- 'ttl' => $bridge_infos['permit_join_timeout'] * 1000
+ 'ttl' => $bridge_infos['permit_join_end'] - time() * 1000
));
}
?>
From 276d290230ad0d659709cf3e5ffbdb2be680634c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Mon, 7 Apr 2025 14:33:05 +0200
Subject: [PATCH 07/11] Update z2m.php
displays alert with ttl in seconds
---
mobile/html/z2m.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mobile/html/z2m.php b/mobile/html/z2m.php
index f57d8963..998440dc 100644
--- a/mobile/html/z2m.php
+++ b/mobile/html/z2m.php
@@ -26,11 +26,12 @@
sendVarToJS('devices_attr', $deviceAttr);
$bridge_infos = z2m::getDeviceInfo('bridge1');
if($bridge_infos['permit_join'] && isset($bridge_infos['permit_join_end'])){
+ $ttl = $bridge_infos['permit_join_end'] - time() * 1000;
event::add('jeedom::alert', array(
'level' => 'success',
'page' => 'z2m',
- 'message' => __('Mode inclusion actif', __FILE__),
- 'ttl' => $bridge_infos['permit_join_end'] - time() * 1000
+ 'message' => __('Mode inclusion actif pendant '. intdiv($ttl, 1000) . 's', __FILE__),
+ 'ttl' => $ttl
));
}
?>
From 0a15dce0f0cff69885a513ccca5928884d76a616 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Mon, 7 Apr 2025 16:05:38 +0200
Subject: [PATCH 08/11] Update z2m.class.php
time is new value to check include mode
---
core/class/z2m.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/class/z2m.class.php b/core/class/z2m.class.php
index b5729b67..a640a2e3 100644
--- a/core/class/z2m.class.php
+++ b/core/class/z2m.class.php
@@ -570,7 +570,7 @@ public static function handle_bridge($_datas) {
log::add('z2m', 'error', __('Z2M à renvoyé une erreur : ', __FILE__) . json_encode($_datas['response']));
}
if (isset($_datas['response']['permit_join'])) {
- if ($_datas['response']['permit_join']['data']['value']) {
+ if ($_datas['response']['permit_join']['data']['time'] > 0) {
event::add('jeedom::alert', array(
'level' => 'success',
'page' => 'z2m',
From c07200b9597313ad76cbc40953869f90420b4520 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Thu, 10 Jul 2025 10:52:44 +0200
Subject: [PATCH 09/11] Update post-install.sh
update pnpm
---
resources/post-install.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/post-install.sh b/resources/post-install.sh
index aeed2ba8..94208ab4 100644
--- a/resources/post-install.sh
+++ b/resources/post-install.sh
@@ -41,7 +41,7 @@ if [ -n "${wanted_z2m_version}" ] && [ $(echo $wanted_z2m_version | head -c 1) -
npm ci
npm run build
else
- npm install -g pnpm@10.4.1
+ npm install -g pnpm@10.12.1
pnpm i --frozen-lockfile
pnpm run build
fi
From 327c481abad3572980d1b41d71b09dba98e68d2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Thu, 10 Jul 2025 12:26:02 +0200
Subject: [PATCH 10/11] Update z2m.ajax.php
---
core/ajax/z2m.ajax.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/ajax/z2m.ajax.php b/core/ajax/z2m.ajax.php
index 7fec40bd..808dc07e 100644
--- a/core/ajax/z2m.ajax.php
+++ b/core/ajax/z2m.ajax.php
@@ -28,7 +28,7 @@
if (init('action') == 'include') {
$data = array(
'value' => (init('mode') == 1),
- 'time' => 180
+ 'time' => (init('mode') == 1) ? 180 : 0
);
if(init('id') != 'all'){
$data['device'] = init('id');
From ddecf259d8610914f04c14cc35399e3c82fdc087 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9rald=20Gatesoupe?=
<41824575+Ultraboss77@users.noreply.github.com>
Date: Tue, 26 Aug 2025 16:23:15 +0200
Subject: [PATCH 11/11] Update z2m.class.php
---
core/class/z2m.class.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/core/class/z2m.class.php b/core/class/z2m.class.php
index 6ad48f3a..5ec871f9 100644
--- a/core/class/z2m.class.php
+++ b/core/class/z2m.class.php
@@ -570,12 +570,12 @@ public static function handle_bridge($_datas) {
));*/
break;
case 'error':
- log::add('z2m', 'error', __('Z2M à renvoyé une erreur : ', __FILE__) . $_datas['logging']['message']);
+ log::add('z2m', 'error', __('Z2M a renvoyé une erreur : ', __FILE__) . $_datas['logging']['message']);
break;
}
}
if (isset($_datas['response']['status']) && $_datas['response']['status'] != 'ok') {
- log::add('z2m', 'error', __('Z2M à renvoyé une erreur : ', __FILE__) . json_encode($_datas['response']));
+ log::add('z2m', 'error', __('Z2M a renvoyé une erreur : ', __FILE__) . json_encode($_datas['response']));
}
if (isset($_datas['response']['permit_join'])) {
if ($_datas['response']['permit_join']['data']['time'] > 0) {