Compare commits
No commits in common. "1d44bd62e2eaa461d6ea845ab3c285621dce8ce3" and "2410441b889ba8ba321938dc87c24c7a48dba4eb" have entirely different histories.
1d44bd62e2
...
2410441b88
11
README.md
11
README.md
@ -136,17 +136,6 @@ Distributed under the MIT License. See `LICENSE` for more information.
|
||||
Project Link: [https://github.com/GamerClassN7/Smart_Home/](https://github.com/GamerClassN7/Smart_Home/) <br> <br>
|
||||
<sup><sub>Tags (ignore): ESP32 ESP12 ESP08 ESP01 ESP Smart Home Automation System PWA PHP HTML JS DHT11 DHT22
|
||||
|
||||
## Code Statistics
|
||||
Type | Files | Lines
|
||||
-----|-------|-----------
|
||||
php | 2 | 2298 (89%)
|
||||
md | 1 | 171 (7%)
|
||||
js | 1 | 64 (2%)
|
||||
sh | 1 | 34 (1%)
|
||||
json | 1 | 10 (0.4%)
|
||||
-----|-------|-----------
|
||||
All | 6 | 2577
|
||||
|
||||
## Folder structure
|
||||
```
|
||||
- /app # app specific files
|
||||
|
@ -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'], 'plugin');
|
||||
RecordManager::create($deviceId, $this->subdevice_type, $json['data']['aqi']);
|
||||
} else {
|
||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');
|
||||
DeviceManager::approved($this->virtual_device_name);
|
||||
|
@ -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'], 'plugin');
|
||||
RecordManager::create($deviceId, $this->subdevice_type, $json['data']['aqi']);
|
||||
} else {
|
||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');
|
||||
DeviceManager::approved($this->virtual_device_name);
|
||||
|
@ -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]], 'plugin');
|
||||
RecordManager::create($deviceId, strtolower($dataItem), end($json)[$this->name_index[$dataItem]]);
|
||||
}
|
||||
} else {
|
||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, strtolower($this->virtual_device_name));
|
||||
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
class DameJidlo extends VirtualDeviceManager
|
||||
{
|
||||
private $virtual_device_name = "Dáme Jídlo";
|
||||
private $device_type = "virtual-device";
|
||||
private $subdevice_type = "dame-jidlo";
|
||||
|
||||
public function deliveryTime($token)
|
||||
{
|
||||
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://cz.fd-api.com/api/v5/tracking/active-orders?time_variation=Variation2');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
||||
|
||||
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
|
||||
|
||||
$headers = array();
|
||||
$headers[] = 'Authority: cz.fd-api.com';
|
||||
$headers[] = 'Sec-Ch-Ua: \"Chromium\";v=\"88\", \"Google Chrome\";v=\"88\", \";Not A Brand\";v=\"99\"';
|
||||
$headers[] = 'Accept: application/json, text/plain, */*';
|
||||
$headers[] = 'Authorization: Bearer ' . $token;
|
||||
$headers[] = 'X-Pd-Language-Id: 2';
|
||||
$headers[] = 'Sec-Ch-Ua-Mobile: ?0';
|
||||
$headers[] = 'X-Fp-Api-Key: volo';
|
||||
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36';
|
||||
$headers[] = 'Origin: https://www.damejidlo.cz';
|
||||
$headers[] = 'Sec-Fetch-Site: cross-site';
|
||||
$headers[] = 'Sec-Fetch-Mode: cors';
|
||||
$headers[] = 'Sec-Fetch-Dest: empty';
|
||||
$headers[] = 'Referer: https://www.damejidlo.cz/';
|
||||
$headers[] = 'Accept-Language: en-US,en;q=0.9,cs-CZ;q=0.8,cs;q=0.7';
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
echo 'Error:' . curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
return (isset(json_decode($result, true)['data']['active_orders'][0]['delivery']['time']['eta']) ? json_decode($result, true)['data']['active_orders'][0]['delivery']['time']['eta'] : 0);
|
||||
}
|
||||
|
||||
function make()
|
||||
{
|
||||
//Register the settings
|
||||
$settingMng = new SettingsManager();
|
||||
if (!($settingField = $settingMng->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 '';
|
||||
}
|
||||
}
|
@ -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, 'plugin');
|
||||
RecordManager::create($deviceId, $this->subdevice_type, $daysUntilN7Day);
|
||||
} else {
|
||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, $this->device_type);
|
||||
DeviceManager::approved($this->virtual_device_name);
|
||||
|
@ -55,7 +55,7 @@ class OpenWeatherMap extends VirtualDeviceManager
|
||||
}
|
||||
|
||||
|
||||
RecordManager::create($deviceId, $this->subdevice_type, $json['weather'][0]['id'], 'plugin');
|
||||
RecordManager::create($deviceId, $this->subdevice_type, $json['weather'][0]['id']);
|
||||
} else {
|
||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');
|
||||
DeviceManager::approved($this->virtual_device_name);
|
||||
|
@ -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)), 'plugin');
|
||||
RecordManager::create($deviceId, strtolower($Category), round(($$Category / $OnePercent)));
|
||||
}
|
||||
} else {
|
||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');
|
||||
|
Loading…
Reference in New Issue
Block a user