Heimdall-Apps/MySpeed/MySpeed.php
Lucas Araujo 0c395214a8
feat: add MySpeed app integration with live stats and config (#869)
* feat: add MySpeed app integration with live stats and config

- Implement MySpeed app with live statistics display for download/upload speeds
- Add configuration page with URL override option
- Include app icon and metadata in app.json

* style: format constructor with consistent spacing

* refactor: remove empty line in MySpeed constructor

---------

Co-authored-by: Lucas Araujo <lucas.ribeiro.de.araujo@rabobank.nl>
2025-09-20 16:15:44 +02:00

44 lines
957 B
PHP

<?php
namespace App\SupportedApps\MySpeed;
class MySpeed extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;
public function __construct() {
}
public function test()
{
$test = parent::appTest($this->url('api/info/version'));
echo $test->status;
}
public function livestats()
{
$status = 'inactive';
$res = parent::execute($this->url('api/speedtests/statistics'));
$details = json_decode($res->getBody());
$data = [];
if ($details) {
$status = 'active';
$data = [
'avg_down' => floor($details->download->avg),
'avg_up' => floor($details->upload->avg)
];
}
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
return $api_url;
}
}