Some Tweeks
This commit is contained in:
parent
c410df1bd6
commit
5d32c2bfa4
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
class WidgetApi extends ApiController{
|
||||
class WidgetApi extends ApiController
|
||||
{
|
||||
|
||||
public function run($subDeviceId){
|
||||
public function run($subDeviceId)
|
||||
{
|
||||
//$this->requireAuth();
|
||||
|
||||
$response = null;
|
||||
@ -30,7 +32,8 @@ class WidgetApi extends ApiController{
|
||||
$this->response(['value' => $response]);
|
||||
}
|
||||
|
||||
public function detail($subDeviceId){
|
||||
public function detail($subDeviceId)
|
||||
{
|
||||
//$this->requireAuth();
|
||||
$response = null;
|
||||
$connectionError = true;
|
||||
@ -70,10 +73,11 @@ class WidgetApi extends ApiController{
|
||||
$response = [
|
||||
'records' => $events,
|
||||
'graph' => [
|
||||
'labels' => $labels,
|
||||
'data' => [
|
||||
'labels' => $labels,
|
||||
'dataset' => $values
|
||||
],
|
||||
'options' => [
|
||||
'scales' => [
|
||||
'xAxis' => [
|
||||
'type' => 'time',
|
||||
@ -97,6 +101,7 @@ class WidgetApi extends ApiController{
|
||||
'mode' => true
|
||||
],
|
||||
],
|
||||
],
|
||||
'comError' => $connectionError,
|
||||
'lastConnectionTime' => (empty($niceTime) ? "00:00" : $niceTime),
|
||||
];
|
||||
|
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
class Covid extends VirtualDeviceManager {
|
||||
class Covid extends VirtualDeviceManager
|
||||
{
|
||||
private $country_sluig = "czech-republic";
|
||||
private $api_uri = 'https://api.covid19api.com/live/country/%s/status/confirmed'; // Your redirect uri
|
||||
private $virtual_device_name = "Covid";
|
||||
|
||||
function fetch($url = 'true')
|
||||
{
|
||||
|
||||
if (DeviceManager::registeret($this->virtual_device_name)) {
|
||||
$deviceId = DeviceManager::getDeviceByToken($this->virtual_device_name)['device_id'];
|
||||
$dataItems = ['Confirmed', 'Deaths', 'Recovered', 'Active'];
|
||||
foreach ($dataItems as $dataItem) {
|
||||
if (!$subDevice = SubDeviceManager::getSubDeviceByMaster($deviceId, strtolower($dataItem))) {
|
||||
SubDeviceManager::create($deviceId, strtolower($dataItem), 'Cases');
|
||||
SubDeviceManager::create($deviceId, strtolower($dataItem), $dataItem);
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ class OpenWeatherMap extends VirtualDeviceManager
|
||||
$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);
|
||||
}
|
||||
|
||||
if (!$this->fetchEnabled($deviceId,$subDevice['subdevice_id'])) die();
|
||||
|
Loading…
Reference in New Issue
Block a user