diff --git a/app/plugins/!AirQuality.php b/app/plugins/!AirQuality.php index df5ac34..4975722 100644 --- a/app/plugins/!AirQuality.php +++ b/app/plugins/!AirQuality.php @@ -22,7 +22,7 @@ class AirQuality extends VirtualDeviceManager $finalUrl = sprintf($this->api_uri, $this->city_sluig, $this->app_id); $json = json_decode(Utilities::CallAPI('GET', $finalUrl, ''), true); - RecordManager::create($deviceId, $this->subdevice_type, $json['data']['aqi']); + RecordManager::create($deviceId, $this->subdevice_type, $json['data']['aqi'], 'plugin'); } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual'); DeviceManager::approved($this->virtual_device_name); diff --git a/app/plugins/AirQuality.php b/app/plugins/AirQuality.php index 7f76132..9bf5a88 100644 --- a/app/plugins/AirQuality.php +++ b/app/plugins/AirQuality.php @@ -30,7 +30,7 @@ class AirQuality extends VirtualDeviceManager $finalUrl = sprintf($this->api_uri, $this->city_sluig, $this->app_id); $json = json_decode(Utilities::CallAPI('GET', $finalUrl, ''), true); - RecordManager::create($deviceId, $this->subdevice_type, $json['data']['aqi']); + RecordManager::create($deviceId, $this->subdevice_type, $json['data']['aqi'], 'plugin'); } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual'); DeviceManager::approved($this->virtual_device_name); diff --git a/app/plugins/CovidV2.php b/app/plugins/CovidV2.php index b5f4971..1ff3251 100644 --- a/app/plugins/CovidV2.php +++ b/app/plugins/CovidV2.php @@ -31,7 +31,7 @@ class CovidV2 extends VirtualDeviceManager $json = json_decode(Utilities::CallAPI('GET', $finalUrl, ''), true)['data']; foreach ($dataItems as $dataItem) { - RecordManager::create($deviceId, strtolower($dataItem), end($json)[$this->name_index[$dataItem]]); + RecordManager::create($deviceId, strtolower($dataItem), end($json)[$this->name_index[$dataItem]], 'plugin'); } } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, strtolower($this->virtual_device_name)); diff --git a/app/plugins/DameJidlo.php b/app/plugins/DameJidlo.php new file mode 100644 index 0000000..a9d87bc --- /dev/null +++ b/app/plugins/DameJidlo.php @@ -0,0 +1,85 @@ +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 ''; + } +} diff --git a/app/plugins/N7day.php b/app/plugins/N7day.php index 31301d7..6725645 100644 --- a/app/plugins/N7day.php +++ b/app/plugins/N7day.php @@ -29,7 +29,7 @@ class N7Day extends VirtualDeviceManager $datediff = $now - $your_date; $daysUntilN7Day = round($datediff / (60 * 60 * 24)); - RecordManager::create($deviceId, $this->subdevice_type, $daysUntilN7Day); + RecordManager::create($deviceId, $this->subdevice_type, $daysUntilN7Day, 'plugin'); } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, $this->device_type); DeviceManager::approved($this->virtual_device_name); diff --git a/app/plugins/OpenWeatherMap.php b/app/plugins/OpenWeatherMap.php index 36c2386..5fbedc0 100644 --- a/app/plugins/OpenWeatherMap.php +++ b/app/plugins/OpenWeatherMap.php @@ -55,7 +55,7 @@ class OpenWeatherMap extends VirtualDeviceManager } - RecordManager::create($deviceId, $this->subdevice_type, $json['weather'][0]['id']); + RecordManager::create($deviceId, $this->subdevice_type, $json['weather'][0]['id'], 'plugin'); } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual'); DeviceManager::approved($this->virtual_device_name); diff --git a/app/plugins/UsaElection.php b/app/plugins/UsaElection.php index 1cf7323..fd9dad8 100644 --- a/app/plugins/UsaElection.php +++ b/app/plugins/UsaElection.php @@ -52,7 +52,7 @@ class UsaElection extends VirtualDeviceManager $OnePercent = ($Trump + $Biden + $Unknown) / 100; foreach ($dataItems as $Category) { - RecordManager::create($deviceId, strtolower($Category), round(($$Category / $OnePercent))); + RecordManager::create($deviceId, strtolower($Category), round(($$Category / $OnePercent)), 'plugin'); } } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');