getByName("damejidlo_token","damejidlo"))) { $settingMng->create("damejidlo_token", "", "damejidlo"); } else { $bearer = $settingField['value']; } try { if (DeviceManager::registeret($this->virtual_device_name)) { $deviceId = DeviceManager::getDeviceByToken($this->virtual_device_name)['device_id']; if (!$subDevice = SubDeviceManager::getSubDeviceByMaster($deviceId, $this->subdevice_type)) { SubDeviceManager::create($deviceId, $this->subdevice_type, ''); sleep(1); $subDevice = SubDeviceManager::getSubDeviceByMaster($deviceId, strtolower($this->subdevice_type)); } //if (!$this->fetchEnabled($deviceId,$subDevice['subdevice_id'])) die(); RecordManager::create($deviceId, $this->subdevice_type, $this->deliveryTime($bearer), 'plugin'); } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual'); DeviceManager::approved($this->virtual_device_name); } return 'sucessful'; } catch (Exception $e) { return 'exception: ' . $e->getMessage(); } } function translate($value){ if ($value == 0) { return " Delivered"; } else if ($value <= 1) { return "less " . $value; } return $value; } }