/**
  * Domoticz Pages Methodes
  *
  **/
 function action_add($_)
 {
     $idx = $_['idx'];
     //TODO search by idx
     $devices = $this->domoticzApi->getDevices();
     if (is_array($devices)) {
         foreach ($devices as $row2) {
             if ($idx == $row2['idx']) {
                 $domoticz = new DomoticzCmd();
                 $domoticz->setIdx($row2['idx']);
                 $domoticz->setType($row2['Type']);
                 $domoticz->setDevice($row2['Name']);
                 $domoticz->setCategorie($row2['categorie']);
                 if ($row2['Type'] == 'Scene') {
                     $domoticz->setCmdOn('mode ' . $row2['Name']);
                     $domoticz->setReponsesOn(str_replace('{NAME}', $row2['Name'], $this->phrases['switchscene']['On']));
                 } else {
                     if ($row2['categorie'] == 'mesure') {
                         $domoticz->setCmdOn($row2['Name']);
                         $domoticz->setReponsesOn($this->phrases[$row2['categorie']]);
                     } else {
                         if ($row2['categorie'] == 'variable') {
                             $domoticz->setCmdOn('valeur ' . $row2['Name']);
                             $domoticz->setReponsesOn($this->phrases[$row2['categorie']]);
                         } else {
                             if ($row2['categorie'] == 'utility') {
                                 $domoticz->setCmdOn('valeur ' . $row2['Name']);
                                 $domoticz->setReponsesOn($this->phrases[$row2['categorie']]);
                             } else {
                                 $domoticz->setCmdOn('allume ' . $row2['Name']);
                                 $domoticz->setCmdOff('eteint ' . $row2['Name']);
                                 $domoticz->setReponsesOn(str_replace('{NAME}', $row2['Name'], $this->phrases['switchlight']['On']));
                                 $domoticz->setReponsesOff(str_replace('{NAME}', $row2['Name'], $this->phrases['switchlight']['Off']));
                             }
                         }
                     }
                 }
                 $domoticz->setConfidence(0.8);
                 $domoticz->setVocal(true);
                 $domoticz->save();
                 header('location:setting.php?section=' . $this->section . '&block=new&save=ok');
             }
         }
     }
 }