no message

This commit is contained in:
2025-11-14 08:35:11 +01:00
parent 118e126c7c
commit 8e198c174e
3 changed files with 49 additions and 49 deletions
+45
View File
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
class ShellyParser
{
/** Modell aus src extrahieren */
public static function ExtractType(string $src): string
{
// Beispiel: "shelly1g4-12345"
if (!str_starts_with($src, "shelly")) {
return "unknown";
}
$str = substr($src, 6); // "1g4-12345"
$parts = explode("-", $str); // ["1g4", "12345"]
return $parts[0] ?? "unknown";
}
/** generisches Mapping für Shelly Daten */
public static function MapParams(array $params): array
{
$mapped = [];
foreach ($params as $key => $val) {
if ($key === "input") {
$mapped["input"] = (bool)$val;
}
if ($key === "output") {
$mapped["output"] = (bool)$val;
}
if ($key === "temperature" || $key === "temp") {
$mapped["temperature"] = (float)$val;
}
// weitere Shelly-Geräte können später hier ergänzt werden
}
return $mapped;
}
}