/** * This action will return the power state of each device specified in the database. * * @return A JSON encoded object with the state of each device */ public function stateAction() { $device = Devices::findFirst(array('conditions' => 'ip = ?1', 'bind' => array(1 => $_GET['ip']))); $state['state'] = Devices::isDeviceOn($device->ip); $state['ip'] = $device->ip; die(json_encode($state)); }