Skip to content

Commit

Permalink
Inclusion d un equipement inconnu alors ca part en exponentiel de mes…
Browse files Browse the repository at this point in the history
…sage. #993
  • Loading branch information
KiwiHC16 committed Mar 5, 2020
1 parent 6ec18b2 commit 6522077
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
27 changes: 8 additions & 19 deletions core/class/Abeille.class.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public static function deamon_start($_debug = false) {

// ----------------

if ( ($param['AbeilleSerialPort1'] == "/dev/zigate1") and ($param['AbeilleActiver1']=='Y') ) {
if ( ($param['AbeilleSerialPort1'] == "/dev/zigate") and ($param['AbeilleActiver1']=='Y') ) {
$cmd = $nohup." ".$php." ".$dirdeamon.$deamon21." ".$paramdeamon21.$log21;
log::add('Abeille', 'debug', 'Start deamon socat: '.$cmd);
exec($cmd.' 2>&1 &');
Expand Down Expand Up @@ -1089,7 +1089,6 @@ public static function message($message) {

// log::add('Abeille', 'debug', 'I should have the cmd now' );

$objetConnu = 0;
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
// Si l objet n existe pas et je recoie son nom => je créé l objet.
if ( !is_object($elogic)
Expand Down Expand Up @@ -1125,16 +1124,9 @@ public static function message($message) {
$AbeilleObjetDefinition = json_decode($AbeilleObjetDefinitionJson, true);
log::add('Abeille', 'debug', 'Template mis a jour avec EP: '.json_encode($AbeilleObjetDefinition));

//Due to various kind of naming of devices, json object is either named as value or $trimmedvalue. We need to know which one to use.
if (array_key_exists($value, $AbeilleObjetDefinition) || array_key_exists( $trimmedValue, $AbeilleObjetDefinition )) {
$objetConnu = 1;
$jsonName = array_key_exists($value, $AbeilleObjetDefinition) ? $value : $trimmedValue;
log::add( 'Abeille', 'info', 'objet: '.$value.' recherché comme '.$trimmedValue.' peut etre cree car je connais ce type d objet.' );
} else {
log::add( 'Abeille', 'info', 'objet: '.$value.' recherché comme '.$trimmedValue.' ne peut pas etre creer car je ne connais pas ce type d objet.' );
// log::add('Abeille', 'debug', 'objet: '.json_encode($AbeilleObjetDefinition));
return;
}

if ( array_key_exists( $trimmedValue, $AbeilleObjetDefinition) ) { $jsonName = $trimmedValue; }
if ( array_key_exists('defaultUnknown', $AbeilleObjetDefinition) ) { $jsonName = 'defaultUnknown'; }

/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
// Creation de l objet Abeille
Expand All @@ -1148,13 +1140,8 @@ public static function message($message) {
message::add( "Abeille", "Création d un nouvel objet Abeille (".$nodeid.") en cours, dans quelques secondes rafraîchissez votre dashboard pour le voir.",'','Abeille/Abeille' );
$elogic = new Abeille();
//id
if ($objetConnu) {
// $name = "Abeille-".$addr;
// $name = "Abeille-" . $addr . '-' . $jsonName;
$name = $Filter."-".$addr;
} else {
$name = "Abeille-".$addr.'-'.$jsonName."-Type d objet inconnu (!JSON)";
}

$name = $Filter."-".$addr;
$elogic->setName($name);
$elogic->setLogicalId($nodeid);
$elogic->setObject_id($parameters_info['AbeilleParentId']);
Expand All @@ -1163,13 +1150,15 @@ public static function message($message) {
$objetDefSpecific = $AbeilleObjetDefinition[$jsonName];

$objetConfiguration = $objetDefSpecific["configuration"];
log::add('Abeille', 'debug', 'Template configuration: '.json_encode($objetConfiguration));
$elogic->setConfiguration('topic', $nodeid);
$elogic->setConfiguration('type', $type);
$elogic->setConfiguration('uniqId', $objetConfiguration["uniqId"]);
$elogic->setConfiguration('icone', $objetConfiguration["icone"]);
$elogic->setConfiguration('mainEP', $objetConfiguration["mainEP"]);
$elogic->setConfiguration('lastCommunicationTimeOut', $objetConfiguration["lastCommunicationTimeOut"]);
$elogic->setConfiguration('type', $type);

if (isset($objetConfiguration['battery_type'])) {
$elogic->setConfiguration('battery_type', $objetConfiguration['battery_type']);
}
Expand Down
24 changes: 24 additions & 0 deletions core/config/devices/defaultUnknown/defaultUnknown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"defaultUnknown": {
"nameJeedom": "defaultUnknown",
"timeout": "60",
"Categorie": {
"security": "1"
},
"configuration": {
"uniqId": "5cfdgh0asd6rt78620b6b",
"icone": "defaultUnknown",
"mainEP": "#EP#",
"poll": "1"
},
"Commandes": {
"include1": "nom",
"include2": "societe",
"include3": "SW",
"include21": "getManufacturerName",
"include22": "getModelIdentifier",
"include23": "getSWBuild",
"include24": "Identify"
}
}
}
Binary file added images/node_defaultUnknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion resources/AbeilleDeamon/lib/Tools.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ public static function getJSonConfigFilebyDevicesTemplate($device = 'none') {
$deviceCmds = array();
$deviceFilename = dirname(__FILE__) . '/../../../core/config/devices/' . $device . '/' . $device . '.json';

if (!is_file($deviceFilename)) { return; }
if (!is_file($deviceFilename)) {
log::add('Abeille', 'error', 'getJSonConfigFilebyDevices: filename not found: ' . $deviceFilename . ' will send back default template.');
$device = 'defaultUnknown';
$deviceFilename = dirname(__FILE__) . '/../../../core/config/devices/' . $device . '/' . $device . '.json';
}

$content = file_get_contents($deviceFilename);

Expand Down

0 comments on commit 6522077

Please sign in to comment.