Skip to content
Permalink
Browse files

Update zigbee2mqtt.class.php

  • Loading branch information...
directman66 committed Apr 9, 2019
1 parent 6110ad0 commit 338daff9b84097dee8b6830c9be3a1a7b66efc0d
Showing with 17 additions and 5 deletions.
  1. +17 −5 modules/zigbee2mqtt/zigbee2mqtt.class.php
@@ -475,7 +475,18 @@ function processMessage($path, $value) {
$rec['IEEEADDR']=$dev_title;
$rec['FIND']=date('Y-m-d H:i:s');
SQLInsert('zigbee2mqtt_devices', $rec);
if ($rec['TITLE']=='bridge' ){
$cnt=SQLSelectOne("SELECT count(*) cnt FROM zigbee2mqtt_devices WHERE TITLE ='bridge'")['cnt'];
echo $cnt;
if ($cnt==0) SQLInsert('zigbee2mqtt_devices', $rec);
}
else SQLInsert('zigbee2mqtt_devices', $rec);
// $this->refresh_db();
$this->refreshdb_mqtt();
@@ -1143,6 +1154,7 @@ function updatedb() {
function refresh_db() {
/*
$this->getConfig();
$zigbee2mqttpath=$this->config['ZIGBEE2MQTTPATH'];
$filename=$zigbee2mqttpath.'/data/database.db';
@@ -1189,7 +1201,7 @@ function refresh_db() {
$res=SQLSelectOne($sql);
if($res['ID'])
{ /* If path_write foud in db */
/*
foreach ($json as $key=> $value) {
if ($key=='type') $res['TYPE']=$value;
if ($key=='nwkAddr') $res['NWKADDR']=$value;
@@ -1207,7 +1219,7 @@ function refresh_db() {
$this->updateparrent();
//debmes('123', 'zigbee2mqtt');
}
*/
}
@@ -1286,11 +1298,11 @@ function refreshdb_mqtt() {
$res2['TITLE']=$res2['IEEEADDR'];
debmes($res2, 'zigbee2mqtt');
if (($res2['TITLE'])&&($res2['TYPE']!='Coordinator')) SQLInsert('zigbee2mqtt_devices', $res2);
if (($res2['TITLE'])&&($res2['TYPE']!='Coordinator')&&($res2['TITLE']!='bridge')) SQLInsert('zigbee2mqtt_devices', $res2);
}
if ($res2['TYPE']=='Coordinator') SQLExec('update zigbee2mqtt_devices set SELECTVENDOR="Texas Instruments", SELECTTYPE="cc2531", IEEEADDR="'.$res2['IEEEADDR'].'" where TITLE="bridge"', $res2);
if ($res2['TYPE']=='Coordinator') SQLExec ('update zigbee2mqtt_devices set SELECTVENDOR="Texas Instruments", SELECTTYPE="cc2531", IEEEADDR="'.$res2['IEEEADDR'].'" where TITLE="bridge"', $res2);
}

0 comments on commit 338daff

Please sign in to comment.
You can’t perform that action at this time.