Weather notifications
This commit is contained in:
parent
cb45cf9e22
commit
dc77534bad
@ -23,6 +23,38 @@ class OpenWeatherMap extends VirtualDeviceManager
|
|||||||
$finalUrl = sprintf($this->api_uri, $this->city_sluig, $this->app_id);
|
$finalUrl = sprintf($this->api_uri, $this->city_sluig, $this->app_id);
|
||||||
$json = json_decode(Utilities::CallAPI('GET', $finalUrl, ''), true);
|
$json = json_decode(Utilities::CallAPI('GET', $finalUrl, ''), true);
|
||||||
|
|
||||||
|
|
||||||
|
//Notification data setup
|
||||||
|
$notificationMng = new NotificationManager;
|
||||||
|
if ($json['weather'][0]['id'] >= 500 && $json['weather'][0]['id'] < 600) {
|
||||||
|
// $notificationData = [
|
||||||
|
// 'title' => 'Weather',
|
||||||
|
// 'body' => 'It Will be rainy outhere, Take Umbrela :)',
|
||||||
|
// 'icon' => 'http://dev.steelants.cz/projekty/simplehome-client/img/icons/favicon-16x16.png',
|
||||||
|
// ];
|
||||||
|
// //Notification for newly added Device
|
||||||
|
// if ($notificationData != []) {
|
||||||
|
// $subscribers = $notificationMng::getSubscription();
|
||||||
|
// foreach ($subscribers as $key => $subscriber) {
|
||||||
|
// $notificationMng::sendSimpleNotification(SERVERKEY, $subscriber['token'], $notificationData);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
} else if ($json['weather'][0]['id'] >= 600 && $json['weather'][0]['id'] < 700) {
|
||||||
|
// $notificationData = [
|
||||||
|
// 'title' => 'Weather',
|
||||||
|
// 'body' => 'It is white out there :)',
|
||||||
|
// 'icon' => 'http://dev.steelants.cz/projekty/simplehome-client/img/icons/favicon-16x16.png',
|
||||||
|
// ];
|
||||||
|
// //Notification for newly added Device
|
||||||
|
// if ($notificationData != []) {
|
||||||
|
// $subscribers = $notificationMng::getSubscription();
|
||||||
|
// foreach ($subscribers as $key => $subscriber) {
|
||||||
|
// $notificationMng::sendSimpleNotification(SERVERKEY, $subscriber['token'], $notificationData);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RecordManager::create($deviceId, $this->subdevice_type, $json['weather'][0]['id']);
|
RecordManager::create($deviceId, $this->subdevice_type, $json['weather'][0]['id']);
|
||||||
} else {
|
} else {
|
||||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');
|
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');
|
||||||
|
Loading…
Reference in New Issue
Block a user