/** * 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); }
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())); }
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"; } } }