Example #1
0
    /**
     * Execute hook
     * 
     * @param string $command
     * @param mixed $bootstrap
     * @param Application_Model_Device $device
     * @param array $parameters
     */
    protected function _internalExecute($command,$bootstrap,$device,$parameters){
        if($command == 'xdim'){
            if(!isset ($parameters['intesity']) || $parameters['intesity'] == 0){
                $command = 'off';
            }
            else{
                $intesity = round(($parameters['intesity'] / 100) * 63);

                if(!$device->status_data['on']){
                    //fire on first
                    Octopus_X10_Command::getInstance($bootstrap->getOptions())
                                    ->execute("on", $device->address,null,false);

                    $device->status_data['on'] = 1;
                }
                $device->status_data['intesity'] = $parameters['intesity'];
                
                //update in DB
                Application_Model_DeviceMapper::getInstance()->updateDevice($device);

                return Octopus_X10_Command::getInstance($bootstrap->getOptions())
                    ->execute('xdim', $device->address,$intesity,false);
            }
        }

        return Octopus_X10_Command::getInstance($bootstrap->getOptions())
                ->execute($command, $device->address,null,false);
    }
Example #2
0
 /**
  *
  * @return Application_Model_DeviceMapper
  */
 public static function getInstance()
 {
     if(self::$_instance === null)
     {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
    public function commandAction(){
        $deviceId = $this->_getParam('device_id');
        $command = $this->_getParam('command_name');

        $device = Application_Model_DeviceMapper::getInstance()->getDevice($deviceId);

        $engine = Octopus_Web_Device::factory($device->widget_class);
        if(!$engine){
            return $this->_helper->json(false);
        }

        return $this->_helper->json($engine->execute($command, $device, $this->_request->getParams()));
    }
Example #4
0
 protected function processLamp($eventObject){
     if(($eventObject['type'] == 'Bright' || $eventObject['type'] == 'Dim') &&
             $eventObject['direction'] == 'Tx' && $eventObject['medium'] == 'PL'){
         $model = Application_Model_DeviceMapper::getInstance();
         $address = $eventObject['house'] . $eventObject['device'];
         $deviceObj = $model->getDeviceByAddress('X10', $address);
         if($deviceObj){
             $intesity = (int)$deviceObj->status_data['intesity'];
             $diff = (int)$eventObject['parameter'];
             echo "Old $address intesity is : $intesity, and curr diff is $diff\n";
             if($eventObject['type'] == 'Bright'){
                 $intesity += $diff;
             }
             else{
                 $intesity -= $diff;
             }
             $deviceObj->status_data['intesity'] = $intesity;
             echo "Updating $address intesity: $intesity \n";
             $model->updateDevice($deviceObj);
         }
         else{
             echo "Device $address not found \n";
         }
     }
 }