mirror of
https://git.steelants.cz/SH/PHP_SMART_HOME_V3.git
synced 2026-10-11 17:54:34 +00:00
Weather API Start
This commit is contained in:
1 parent
7f42d49634
commit
0efbda0583
4 files changed
+101
-35
No files matched your search
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
class VirtualDeviceManager
|
||||
{
|
||||
function fetch($url)
|
||||
{
|
||||
$json = json_decode(Utilities::CallAPI('GET', 'api.openweathermap.org/data/2.5/weather?q=prague&appid=1ee609f2fcf8048e84f1d2fb1d1d72b5', ''), true);
|
||||
|
||||
if (DeviceManager::registeret('1ee609f2fcf8048e84f1d2fb1d1d72b5')) {
|
||||
|
||||
$deviceId = DeviceManager::getDeviceByToken('1ee609f2fcf8048e84f1d2fb1d1d72b5')['device_id'];
|
||||
|
||||
if (!SubDeviceManager::getSubDeviceByMaster($deviceId, 'weather-nice')) {
|
||||
SubDeviceManager::create($deviceId, 'weather-nice', '');
|
||||
}
|
||||
|
||||
var_dump($json['weather'][0]);
|
||||
RecordManager::create($deviceId, 'weather-nice', $json['weather'][0]['main']);
|
||||
} else {
|
||||
$deviceId = DeviceManager::create('1ee609f2fcf8048e84f1d2fb1d1d72b5', '1ee609f2fcf8048e84f1d2fb1d1d72b5')['device_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user