forked from fritob/Camper-Monitor
Solar-Integration und dev_watch-Geräte zusammenführen
solar-integration (aus dem separaten VanAligneiOS-Repo) und dev_watch haben unabhängige Git-Historien, decken aber überlappende und sich ergänzende Funktionen ab. Übernommen aus solar-integration: Votronic- Solar-ESP-Anbindung samt Geräterolle, die Live-Activity/Widget-Extension fürs Sperrbildschirm/Dynamic-Island/CarPlay, das Querformat-Layout für Libelle/Fahrzeug-Ansicht und Ausrichtungs-Assistent, sowie die mehreren Fahrzeuggrafik-Stile (Vanster/California). Beibehalten aus dev_watch: alle zusätzlichen Geräteprotokolle (Daly-/JBD-BMS, Alpicool- Kühlbox, WattCycle, Victron), die dort zwischenzeitlich entstanden. Die Xcode-Projektdatei wurde von Hand um die neue Widget-Extension samt SharedActivity-Gruppe erweitert (Datei-synchronisierte Gruppen, kein App-Group-Entitlement nötig). Build für App, Watch und Widget-Extension geprüft (Debug und Release). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
812874baef
commit
e9b9c5bcd5
@@ -0,0 +1,48 @@
|
||||
import Foundation
|
||||
|
||||
/// Zustand des Solarladereglers.
|
||||
struct VotronicSolarESPState: Equatable, Codable, Sendable {
|
||||
var batteryVoltage: Double?
|
||||
var pvVoltage: Double?
|
||||
var pvCurrent: Double?
|
||||
var pvPower: Double?
|
||||
var controllerTemperature: Double?
|
||||
|
||||
var isBatteryCharging: Bool?
|
||||
var isBatteryDischarging: Bool?
|
||||
var isControllerActive: Bool?
|
||||
var isCurrentLimited: Bool?
|
||||
|
||||
var hasReading: Bool {
|
||||
batteryVoltage != nil || pvVoltage != nil || pvCurrent != nil || pvPower != nil
|
||||
}
|
||||
|
||||
/// Kurzer Klartext, wie bei den übrigen Geräten als "Zustand" angezeigt.
|
||||
var stateText: String? {
|
||||
guard isControllerActive != nil else { return nil }
|
||||
if isBatteryCharging == true { return "Lädt" }
|
||||
if isControllerActive == true { return "Aktiv" }
|
||||
return "Inaktiv"
|
||||
}
|
||||
|
||||
func snapshot(deviceID: UUID, rssi: Int?) -> DeviceSnapshot {
|
||||
var snapshot = DeviceSnapshot(deviceID: deviceID, timestamp: Date(), rssi: rssi)
|
||||
snapshot.metrics = [
|
||||
Metric("pv_power", "Solarleistung", pvPower, unit: "W", precision: 0, primary: true),
|
||||
Metric("pv_voltage", "PV-Spannung", pvVoltage, unit: "V", precision: 1),
|
||||
Metric("pv_current", "PV-Strom", pvCurrent, unit: "A", precision: 1),
|
||||
Metric("battery_voltage", "Batteriespannung", batteryVoltage, unit: "V", precision: 2),
|
||||
]
|
||||
if let controllerTemperature {
|
||||
snapshot.metrics.append(
|
||||
Metric("controller_temperature", "Reglertemperatur", controllerTemperature,
|
||||
unit: "°C", precision: 0)
|
||||
)
|
||||
}
|
||||
snapshot.state = stateText
|
||||
if isCurrentLimited == true {
|
||||
snapshot.offReasons = ["PV-Strombegrenzung aktiv"]
|
||||
}
|
||||
return snapshot
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user