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, ''); } if (!$this->fetchEnabled($deviceId,$subDevice['subdevice_id'])) die(); $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['weather'][0]['id']); } else { DeviceManager::create($this->virtual_device_name, $this->virtual_device_name); DeviceManager::approved($this->virtual_device_name); } } }