WIP Citycom ONT Status 2025-12-11
This commit is contained in:
@@ -17,6 +17,65 @@ class SnoppCitycom extends Modules\ApiControllerModule
|
||||
|
||||
}
|
||||
|
||||
public function getOntStatus($req_id) {
|
||||
if(!$req_id) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
}
|
||||
|
||||
$wohneinheit = false;
|
||||
if(is_numeric($req_id)) {
|
||||
$id = $req_id;
|
||||
$wohneinheit = new \ADBWohneinheit($id);
|
||||
}
|
||||
if(!$wohneinheit || !$wohneinheit->id) {
|
||||
$oaid = $req_id;
|
||||
$wohneinheit = \ADBWohneinheitModel::getFirst(["oaid" => $oaid]);
|
||||
if (!$wohneinheit) {
|
||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||
}
|
||||
}
|
||||
|
||||
$cc = new \Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
|
||||
$data = $cc->getOntStatus($wohneinheit->oaid);
|
||||
|
||||
$status = [];
|
||||
$status["online"] = ($data->{"oper-status"} == "present" && $data->status == "Confirmed") ? 1 : 0;
|
||||
$status["uptime"] = ($data->up_time) ? (date('U') - $data->up_time) : null;
|
||||
$status["downtime"] = null;
|
||||
$status["rx"] = $data->{"opt-signal-level"};
|
||||
$status["tx"] = $data->tx_opt_level_dbm;
|
||||
$status["distance"] = null;
|
||||
|
||||
|
||||
return \mfResponse::Ok(["status" => $status]);
|
||||
}
|
||||
|
||||
public function getOntTelemetry($req_id) {
|
||||
if(!$req_id) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
}
|
||||
|
||||
$wohneinheit = false;
|
||||
if(is_numeric($req_id)) {
|
||||
$id = $req_id;
|
||||
$wohneinheit = new \ADBWohneinheit($id);
|
||||
}
|
||||
if(!$wohneinheit || !$wohneinheit->id) {
|
||||
$oaid = $req_id;
|
||||
$wohneinheit = \ADBWohneinheitModel::getFirst(["oaid" => $oaid]);
|
||||
if (!$wohneinheit) {
|
||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||
}
|
||||
}
|
||||
|
||||
$cc = new \Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
|
||||
$data = $cc->getOntStatusDetail($wohneinheit->oaid);
|
||||
|
||||
print_r($data);exit;
|
||||
|
||||
return \mfResponse::Ok(["status" => $status]);
|
||||
}
|
||||
|
||||
public function orderService($req_id) {
|
||||
if(!$req_id) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
|
||||
Reference in New Issue
Block a user