with MaxxiSuns CCU software version v 0.41 (currently beta) it’s possible to import battery data from MaxxiCharge.
The CCU will post data via http-post to a custom url (can be inserted in the local web gui), its format is json: Maxxisun
Does anyone can provide a smart solution to get hands on this values?
As far as I know there is no Homey App for MaxxiSun?
For my personal use, it would be nice to monitor battery level, input and output (from and to battery).
Then I created a new flow with a Logic Card on receiving a new webhook. It works, tested with a notification on receiving a new POST msg.
Earlier I created a new virtual device (with battery, power and so on). Now I dont know how to link the incoming JSON information to the virtual device.
I tried to trigger a HomeyScript, but something is wrong and I dont get it.
// Die ID des virtuellen Geräts
const virtualDeviceId = "ASDF";
// Mappings: Zuordnung der empfangenen Daten zu den Capabilities des virtuellen Geräts
const mappings = {
"voltage": "measure_voltage", // Spannung in Volt
"current": "measure_current", // Stromstärke in Ampere
"power": "measure_power", // Leistung in Watt
"state_of_charge": "measure_battery" // Ladezustand in Prozent
};
// Daten aus den Argumenten des Flows abrufen
const body = args[0]; // JSON-Daten, die im Webhook übergeben wurden
// Überprüfen, ob die empfangenen Daten gültig sind
if (!body || typeof body !== "object") {
throw new Error("Keine oder ungültige Daten übergeben.");
}
// Funktion zum Aktualisieren eines Attributs des virtuellen Geräts
async function updateVirtualDeviceCapability(capability, value) {
try {
await Homey.devices.setCapabilityValue({
deviceId: virtualDeviceId,
capabilityId: capability,
value: value,
});
console.log(`Capability ${capability} erfolgreich auf ${value} aktualisiert.`);
} catch (err) {
console.error(`Fehler beim Aktualisieren von ${capability}:`, err);
}
}
// Die empfangenen Daten verarbeiten
for (const [key, value] of Object.entries(body)) {
const capability = mappings[key];
if (capability) {
await updateVirtualDeviceCapability(capability, value);
} else {
console.warn(`Keine Zuordnung für Schlüssel: ${key}`);
}
}
console.log("Skript abgeschlossen.");