Skip to content

Commit fb429a2

Browse files
authored
Merge pull request #36 from jeedom/beta
to stable
2 parents ba001f9 + 16726d5 commit fb429a2

34 files changed

Lines changed: 639 additions & 157 deletions

core/class/zwavejs.class.php

Lines changed: 36 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ public static function configureSettings($_path) {
188188
// $port = jeedom::getUsbMapping($port);
189189
// exec(system::getCmdSudo() . 'chmod 777 ' . $port . ' > /dev/null 2>&1');
190190
//}
191-
$settings['zwave']['port'] = jeedom::getUsbMapping(config::byKey('port', __CLASS__));
191+
$port = config::byKey('port', __CLASS__);
192+
if ($port == 'tcp') {
193+
$settings['zwave']['port'] = 'tcp://' . config::byKey('tcp_ip_port', __CLASS__);
194+
} else {
195+
$settings['zwave']['port'] = jeedom::getUsbMapping($port);
196+
}
197+
192198
$settings['zwave']['commandsTimeout'] = 60;
193199
$settings['zwave']['logLevel'] = 'error';
194200
$settings['zwave']['logEnabled'] = true;
@@ -281,34 +287,11 @@ public static function postConfig_zwavejs_mode($_value) {
281287
}
282288

283289
public static function additionnalDependancyCheck() {
284-
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
285-
$return = array();
286-
$return['state'] = 'ok';
287-
return $return;
288-
}
289-
$return = array();
290-
$return['state'] = 'ok';
291-
if (config::byKey('lastDependancyInstallTime', __CLASS__) == '') {
292-
$return['state'] = 'nok';
293-
} else if (!file_exists(__DIR__ . '/../../resources/zwave-js-ui/node_modules')) {
294-
$return['state'] = 'nok';
295-
}
296-
return $return;
297-
}
298-
299-
public static function dependancy_info() {
300-
if (config::byKey('zwavejs::mode', 'zwavejs') == 'distant') {
301-
$return = array();
302-
$return['state'] = 'ok';
303-
return $return;
304-
}
305290
$return = array();
306-
$return['progress_file'] = jeedom::getTmpFolder(__CLASS__) . '/dependance';
307-
$return['state'] = 'ok';
308-
if (config::byKey('lastDependancyInstallTime', __CLASS__) == '') {
309-
$return['state'] = 'nok';
310-
} else if (!file_exists(__DIR__ . '/../../resources/zwave-js-ui/node_modules')) {
311-
$return['state'] = 'nok';
291+
if (config::byKey('zwavejs::mode', __CLASS__) === 'local') {
292+
if (!file_exists(__DIR__ . '/../../resources/zwave-js-ui/node_modules')) {
293+
$return['state'] = 'nok';
294+
}
312295
}
313296
return $return;
314297
}
@@ -332,6 +315,16 @@ public static function deamon_info() {
332315
if ($port == 'none') {
333316
$return['launchable'] = 'nok';
334317
$return['launchable_message'] = __("Le port n'est pas configuré", __FILE__);
318+
} elseif ($port == 'tcp') {
319+
if (config::byKey('tcp_ip_port', __CLASS__) == '') {
320+
$return['launchable'] = 'nok';
321+
$return['launchable_message'] = __("Le port TCP n'est pas configuré", __FILE__);
322+
}
323+
$parts = explode(':', config::byKey('tcp_ip_port', __CLASS__));
324+
if (count($parts) != 2 || !is_numeric($parts[1])) {
325+
$return['launchable'] = 'nok';
326+
$return['launchable_message'] = __("Le port TCP n'est pas valide", __FILE__);
327+
}
335328
} else {
336329
$port = jeedom::getUsbMapping($port);
337330
if (is_array($port) || @!file_exists($port)) {
@@ -912,6 +905,7 @@ public static function handleNodeValueUpdate($_value_update) {
912905
public static function handleNodeValueUpdateDirect($_nodeId, $_value_update) {
913906
// log::add(__CLASS__, 'debug', '[' . __FUNCTION__ . '] ' . "Traitement d'un update de value d'un node direct");
914907
//log::add(__CLASS__, 'debug', '[' . __FUNCTION__ . '] ' . $_nodeId . ' ' . json_encode($_value_update));
908+
/** @var zwavejs */
915909
$eqLogic = self::byLogicalId($_nodeId, __CLASS__);
916910
$flatten = self::flatten_array($_value_update);
917911
// log::add(__CLASS__, 'debug', json_encode($flatten, true));
@@ -927,11 +921,7 @@ public static function handleNodeValueUpdateDirect($_nodeId, $_value_update) {
927921
if ($eqLogic->getConfiguration('missedWakeup', false)) {
928922
$action = '<a href="/' . $eqLogic->getLinkToConfiguration() . '">' . __('Equipement', __FILE__) . '</a>';
929923
if (config::byKey('notifyMissWakeup', __CLASS__, 1) == 1 && $eqLogic->getIsEnable() == 1) {
930-
if (version_compare(jeedom::version(), '4.4.0', '>=')) {
931-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ', vient de se réveiller après avoir raté au minimum 4 réveils.', $action, 'Awake-' . $eqLogic->getLogicalId(), true, 'alerting');
932-
} else {
933-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ', vient de se réveiller après avoir raté au minimum 4 réveils.', $action, 'Awake-' . $eqLogic->getLogicalId(), true);
934-
}
924+
message::add('zwavejs', sprintf(__("L'équipement : %s avec le nodeId : %s, vient de se réveiller après avoir raté au minimum 4 réveils.", __FILE__), $eqLogic->getHumanName(true), $eqLogic->getLogicalId()), $action, 'Awake-' . $eqLogic->getLogicalId(), true, 'alerting');
935925
}
936926
}
937927
$eqLogic->setConfiguration('missedWakeup', false);
@@ -940,21 +930,13 @@ public static function handleNodeValueUpdateDirect($_nodeId, $_value_update) {
940930
if ($data['status'] == 'Dead' && $currentValue == 'Alive') {
941931
$action = '<a href="/' . $eqLogic->getLinkToConfiguration() . '">' . __('Equipement', __FILE__) . '</a>';
942932
if (config::byKey('notifyDead', __CLASS__, 1) == 1 && $eqLogic->getIsEnable() == 1) {
943-
if (version_compare(jeedom::version(), '4.4.0', '>=')) {
944-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ', vient de passer au statut Dead.', $action, 'Dead-' . $eqLogic->getLogicalId(), true, 'alerting');
945-
} else {
946-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ', vient de passer au statut Dead.', $action, 'Dead-' . $eqLogic->getLogicalId(), true);
947-
}
933+
message::add('zwavejs', sprintf(__("L'équipement : %s avec le nodeId : %s, vient de passer au statut Dead.", __FILE__), $eqLogic->getHumanName(true), $eqLogic->getLogicalId()), $action, 'Dead-' . $eqLogic->getLogicalId(), true, 'alerting');
948934
}
949935
}
950936
if ($data['status'] == 'Alive' && $currentValue == 'Dead') {
951937
$action = '<a href="/' . $eqLogic->getLinkToConfiguration() . '">' . __('Equipement', __FILE__) . '</a>';
952938
if (config::byKey('notifyDead', __CLASS__, 1) == 1 && $eqLogic->getIsEnable() == 1) {
953-
if (version_compare(jeedom::version(), '4.4.0', '>=')) {
954-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ', vient de passer au statut Alive.', $action, 'Alive-' . $eqLogic->getLogicalId(), true, 'alertingReturnBack');
955-
} else {
956-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ', vient de passer au statut Alive.', $action, 'Alive-' . $eqLogic->getLogicalId(), true);
957-
}
939+
message::add('zwavejs', sprintf(__("L'équipement : %s avec le nodeId : %s, vient de passer au statut Alive.", __FILE__), $eqLogic->getHumanName(true), $eqLogic->getLogicalId()), $action, 'Alive-' . $eqLogic->getLogicalId(), true, 'alertingReturnBack');
958940
}
959941
}
960942
} else if (isset($data['value'])) {
@@ -1472,11 +1454,7 @@ public static function constructHealthPage($_values, $_mobile = False) {
14721454
$eqLogic = self::byLogicalId($values['id'], __CLASS__);
14731455
$productDetails = '<sup><i class="fas fa-question-circle tooltips" title="' . $values['manufacturer'] . ' ' . $values['productDescription'] . ' Firmware : ' . $values['firmwareVersion'] . '"></i><sup>';
14741456
if (is_object($eqLogic)) {
1475-
$image = 'plugins/zwavejs/core/config/devices/' . $eqLogic->getImgFilePath();
1476-
if (!is_file(dirname(__FILE__) . '/../config/devices/' . $eqLogic->getImgFilePath())) {
1477-
$image = 'plugins/zwavejs/plugin_info/zwavejs_icon.png';
1478-
}
1479-
$healthPage .= '<td><img src="' . $image . '" height="40"/> <a href="index.php?v=d&p=zwavejs&m=zwavejs&id=' . $eqLogic->getId() . '">' . $eqLogic->getHumanName(true) . '</a>' . ' ' . $productDetails . '</td>';
1457+
$healthPage .= '<td><img src="' . $eqLogic->getImage() . '" height="40"/> <a href="index.php?v=d&p=zwavejs&m=zwavejs&id=' . $eqLogic->getId() . '">' . $eqLogic->getHumanName(true) . '</a>' . ' ' . $productDetails . '</td>';
14801458
} else {
14811459
$healthPage .= '<td><img src="plugins/zwavejs/plugin_info/zwavejs_icon.png" height="40"/> ' . $values['productLabel'] . ' - ' . $values['productDescription'] . ' ' . $productDetails . '</td>';
14821460
}
@@ -1585,11 +1563,7 @@ public static function constructHealthPage($_values, $_mobile = False) {
15851563
if ($wakedup > 3 * $values['values']['132-0-wakeUpInterval']['value']) {
15861564
$action = '<a href="/' . $eqLogic->getLinkToConfiguration() . '">' . __('Equipement', __FILE__) . '</a>';
15871565
if (config::byKey('notifyMissWakeup', __CLASS__, 1) == 1 && $eqLogic->getIsEnable() == 1) {
1588-
if (version_compare(jeedom::version(), '4.4.0', '>=')) {
1589-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ", ne s'est pas reveillé au moins 4 fois. Il a peut être un problème (batterie ou autres).", $action, 'Wakeup-' . $eqLogic->getLogicalId(), true, 'alertingReturnBack');
1590-
} else {
1591-
message::add('zwavejs', "L'équipement : " . $eqLogic->getHumanName(true) . ' avec le nodeId : ' . $eqLogic->getLogicalId() . ", ne s'est pas reveillé au moins 4 fois. Il a peut être un problème (batterie ou autres).", $action, 'Wakeup-' . $eqLogic->getLogicalId(), true);
1592-
}
1566+
message::add('zwavejs', sprintf(__("L'équipement : %s avec le nodeId : %s, ne s'est pas reveillé au moins 4 fois. Il a peut être un problème (batterie ou autres).", __FILE__), $eqLogic->getHumanName(true), $eqLogic->getLogicalId()), $action, 'Wakeup-' . $eqLogic->getLogicalId(), true, 'alertingReturnBack');
15931567
}
15941568
$eqLogic->setConfiguration('missedWakeup', true);
15951569
$eqLogic->save();
@@ -1605,11 +1579,7 @@ public static function constructHealthPage($_values, $_mobile = False) {
16051579
$healthPage .= '<tr><td>' . $values['id'] . '</td>';
16061580
$eqLogic = self::byLogicalId($values['id'], __CLASS__);
16071581
if (is_object($eqLogic)) {
1608-
$image = 'plugins/zwavejs/core/config/devices/' . $eqLogic->getImgFilePath();
1609-
if (!is_file(dirname(__FILE__) . '/../config/devices/' . $eqLogic->getImgFilePath())) {
1610-
$image = 'plugins/zwavejs/plugin_info/zwavejs_icon.png';
1611-
}
1612-
$healthPage .= '<td><img src="' . $image . '" height="40"/>' . $eqLogic->getHumanName(true) . '</td>';
1582+
$healthPage .= '<td><img src="' . $eqLogic->getImage() . '" height="40"/>' . $eqLogic->getHumanName(true) . '</td>';
16131583
} else {
16141584
$healthPage .= '<td><img src="plugins/zwavejs/plugin_info/zwavejs_icon.png" height="40"/> ' . $values['productLabel'] . ' - ' . $values['productDescription'] . '</td>';
16151585
}
@@ -1757,15 +1727,11 @@ public static function getWaiting() {
17571727
foreach (self::byType(__CLASS__) as $eqLogic) {
17581728
$waitings = $eqLogic->getCache('waiting', array());
17591729
if (is_object($eqLogic)) {
1760-
$image = 'plugins/zwavejs/core/config/devices/' . $eqLogic->getImgFilePath();
1761-
if (!is_file(dirname(__FILE__) . '/../config/devices/' . $eqLogic->getImgFilePath())) {
1762-
$image = 'plugins/zwavejs/plugin_info/zwavejs_icon.png';
1763-
}
17641730
foreach ($waitings as $property => $data) {
17651731
$globWaiting[] = array(
17661732
'id' => $eqLogic->getLogicalId(),
17671733
'eqId' => $eqLogic->getId(),
1768-
'image' => $image,
1734+
'image' => $eqLogic->getImage(),
17691735
'name' => $eqLogic->getHumanName(true),
17701736
'property' => $property,
17711737
'value' => $data['value'],
@@ -2276,9 +2242,15 @@ public function getImgFilePath() {
22762242
}
22772243

22782244
public function getImage() {
2245+
$default = parent::getImage();
2246+
$plugin = plugin::byId(__CLASS__);
2247+
if ($default != $plugin->getPathImgIcon()) {
2248+
return $default; // this is a custom image uploaded by the user, we keep it
2249+
}
2250+
22792251
$file = 'plugins/zwavejs/core/config/devices/' . $this->getImgFilePath();
22802252
if (!is_file(__DIR__ . '/../../../../' . $file)) {
2281-
return 'plugins/zwavejs/plugin_info/zwavejs_icon.png';
2253+
return $default;
22822254
}
22832255
return $file;
22842256
}

core/config/config/Aeotec_0x0371/zwa001.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"valueSize": 2,
5555
"minValue": 5000,
5656
"maxValue": 6500,
57-
"defaultValue": 6500,
57+
"defaultValue": 6500
5858
}
5959
]
6060
}

core/config/devices/fibaro_271/fgwpe.wall.plug.zw5.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"versions": {
88
"1538": [
99
"4099",
10-
"4097"
10+
"4097",
11+
"4100"
1112
]
1213
},
1314
"properties": {
@@ -19,4 +20,4 @@
1920
"type": "multilevel"
2021
}
2122
}
22-
}
23+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "QNDW-002C Shelly Wave Door/Window",
3+
"type": "Ouverture",
4+
"comlink": "",
5+
"remark": "",
6+
"versions": {
7+
"256": [
8+
"129"
9+
]
10+
},
11+
"configuration": {
12+
"battery_type": "CR2032"
13+
},
14+
"properties": {
15+
"Opening": {},
16+
"Luminance": {},
17+
"Direction": {},
18+
"Battery": {},
19+
"Indicator": {},
20+
"Notification|alarmLevel": {"type": "alarmLevel"}
21+
},
22+
"commands": [
23+
{
24+
"name": "Porte (simple)",
25+
"type": "info",
26+
"isVisible": 0,
27+
"isHistorized": 1,
28+
"configuration": {
29+
"class": 113,
30+
"endpoint": 0,
31+
"property": "Access Control-Door state (simple)",
32+
"calculValueOffset": "#value#==22"
33+
},
34+
"subtype": "binary",
35+
"display": {
36+
"invertBinary": "1",
37+
"generic_type": "OPENING"
38+
},
39+
"template": {
40+
"dashboard": "timeDoor",
41+
"mobile": "timeDoor"
42+
}
43+
}
44+
]
45+
}
6.38 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "QLPL-0A112",
3+
"type": "Prise",
4+
"comlink": "",
5+
"remark": "",
6+
"versions": {
7+
"2": [
8+
"135"
9+
]
10+
},
11+
"properties": {
12+
"Switch": {"type": "prise"},
13+
"Indicator": {},
14+
"Power": {},
15+
"Energy": {},
16+
"Notification|heat-sensor": {"type": "heat-sensor"},
17+
"Notification|over-current": {"type": "over-current"},
18+
"Notification|over-voltage": {"type": "over-voltage"},
19+
"Notification|alarmLevel": {"type": "alarmLevel"}
20+
},
21+
"commands": [
22+
{
23+
"name": "Reset consommation kWh",
24+
"type": "action",
25+
"isVisible": 0,
26+
"isHistorized": 0,
27+
"configuration": {
28+
"class": 50,
29+
"endpoint": 0,
30+
"property": "reset-65537",
31+
"value": "true"
32+
},
33+
"subtype": "other",
34+
"display": {
35+
"generic_type": "DONT"
36+
}
37+
},
38+
{
39+
"name": "Identify",
40+
"type": "action",
41+
"isVisible": 0,
42+
"isHistorized": 0,
43+
"configuration": {
44+
"class": 135,
45+
"endpoint": 0,
46+
"property": "identify",
47+
"value": "true"
48+
},
49+
"subtype": "other",
50+
"display": {
51+
"generic_type": "DONT"
52+
}
53+
}
54+
]
55+
}
43.5 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "Zooz / Low Voltage XS Relay",
3+
"ref": "ZEN58",
4+
"manufacturer": "Zooz",
5+
"type": "Relais",
6+
"remark": "",
7+
"versions": {
8+
"4": [
9+
"802"
10+
]
11+
},
12+
"properties": {
13+
"Switch": {"type": "switch"},
14+
"Power": {},
15+
"Energy": {},
16+
"Voltage": {},
17+
"Current": {},
18+
"Indicator": {}
19+
}
20+
}
17.2 KB
Loading

core/config/specific.config.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[atlas]
2+
zwavejs[port] = Jeedom Atlas
3+
4+
[luna]
5+
zwavejs[port] = Jeedom Luna Zwave
6+
7+
[smart]
8+
zwavejs[port] = Jeedom Smart

0 commit comments

Comments
 (0)