Esempio n. 1
0
 public function postInsert()
 {
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Température');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'temp');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Humidité');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'humidity');
     $weatherCmd->setUnite('%');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Pression');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'pressure');
     $weatherCmd->setUnite('Pa');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Condition Actuelle');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Vitesse du vent');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'wind_speed');
     $weatherCmd->setUnite('km/h');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Direction du vent');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'wind_direction');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Lever du soleil');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'sunrise');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Coucher du soleil');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'sunset');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Température Min');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '0');
     $weatherCmd->setConfiguration('data', 'low');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Température Max');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '0');
     $weatherCmd->setConfiguration('data', 'high');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Condition');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '0');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Température Min +1');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '1');
     $weatherCmd->setConfiguration('data', 'low');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Température Max +1');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '1');
     $weatherCmd->setConfiguration('data', 'high');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = new weatherCmd();
     $weatherCmd->setName('Condition +1');
     $weatherCmd->setEqLogic_id($this->id);
     $weatherCmd->setConfiguration('day', '1');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
 }
Esempio n. 2
0
 public function postUpdate()
 {
     $weatherCmd = $this->getCmd(null, 'temperature');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température', __FILE__));
     $weatherCmd->setLogicalId('temperature');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'temp');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'humidity');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Humidité', __FILE__));
     $weatherCmd->setLogicalId('humidity');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'humidity');
     $weatherCmd->setUnite('%');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'pressure');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Pression', __FILE__));
     $weatherCmd->setLogicalId('pressure');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'pressure');
     $weatherCmd->setUnite('Pa');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'condition_now');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Condition Actuelle', __FILE__));
     $weatherCmd->setLogicalId('condition_now');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'wind_speed');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Vitesse du vent', __FILE__));
     $weatherCmd->setLogicalId('wind_speed');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'wind_speed');
     $weatherCmd->setUnite('km/h');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'wind_direction');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Direction du vent', __FILE__));
     $weatherCmd->setLogicalId('wind_direction');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'wind_direction');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'sunset');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Coucher du soleil', __FILE__));
     $weatherCmd->setLogicalId('sunset');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'sunset');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'sunrise');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Lever du soleil', __FILE__));
     $weatherCmd->setLogicalId('sunrise');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '-1');
     $weatherCmd->setConfiguration('data', 'sunrise');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_min');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Min', __FILE__));
     $weatherCmd->setLogicalId('temperature_min');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '0');
     $weatherCmd->setConfiguration('data', 'low');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_max');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Max', __FILE__));
     $weatherCmd->setLogicalId('temperature_max');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '0');
     $weatherCmd->setConfiguration('data', 'high');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'condition');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Condition', __FILE__));
     $weatherCmd->setLogicalId('condition');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '0');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_1_min');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Min +1', __FILE__));
     $weatherCmd->setLogicalId('temperature_1_min');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '1');
     $weatherCmd->setConfiguration('data', 'low');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_1_max');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Max +1', __FILE__));
     $weatherCmd->setLogicalId('temperature_1_max');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '1');
     $weatherCmd->setConfiguration('data', 'high');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_2_min');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Min +2', __FILE__));
     $weatherCmd->setLogicalId('temperature_2_min');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '2');
     $weatherCmd->setConfiguration('data', 'low');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_2_max');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Max +2', __FILE__));
     $weatherCmd->setLogicalId('temperature_2_max');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '2');
     $weatherCmd->setConfiguration('data', 'high');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_3_min');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Min +3', __FILE__));
     $weatherCmd->setLogicalId('temperature_3_min');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '3');
     $weatherCmd->setConfiguration('data', 'low');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_3_max');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Max +3', __FILE__));
     $weatherCmd->setLogicalId('temperature_3_max');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '3');
     $weatherCmd->setConfiguration('data', 'high');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_4_min');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Min +4', __FILE__));
     $weatherCmd->setLogicalId('temperature_4_min');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '4');
     $weatherCmd->setConfiguration('data', 'low');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'temperature_4_max');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Température Max +4', __FILE__));
     $weatherCmd->setLogicalId('temperature_4_max');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '4');
     $weatherCmd->setConfiguration('data', 'high');
     $weatherCmd->setUnite('°C');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('numeric');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'condition_1');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Condition +1', __FILE__));
     $weatherCmd->setLogicalId('condition_1');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '1');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'condition_2');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Condition +2', __FILE__));
     $weatherCmd->setLogicalId('condition_2');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '2');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'condition_3');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Condition +3', __FILE__));
     $weatherCmd->setLogicalId('condition_3');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '3');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $weatherCmd = $this->getCmd(null, 'condition_4');
     if (!is_object($weatherCmd)) {
         $weatherCmd = new weatherCmd();
     }
     $weatherCmd->setName(__('Condition +4', __FILE__));
     $weatherCmd->setLogicalId('condition_4');
     $weatherCmd->setEqLogic_id($this->getId());
     $weatherCmd->setConfiguration('day', '4');
     $weatherCmd->setConfiguration('data', 'condition');
     $weatherCmd->setUnite('');
     $weatherCmd->setType('info');
     $weatherCmd->setEventOnly(1);
     $weatherCmd->setSubType('string');
     $weatherCmd->save();
     $refresh = $this->getCmd(null, 'refresh');
     if (!is_object($refresh)) {
         $refresh = new weatherCmd();
         $refresh->setName(__('Rafraichir', __FILE__));
     }
     $refresh->setEqLogic_id($this->getId());
     $refresh->setLogicalId('refresh');
     $refresh->setType('action');
     $refresh->setSubType('other');
     $refresh->save();
     if ($this->getIsEnable() == 1) {
         $this->reschedule();
     } else {
         $cron = cron::byClassAndFunction('weather', 'pull', array('weather_id' => intval($this->getId())));
         if (is_object($cron)) {
             $cron->remove();
         }
     }
 }