Shelly: add usage and caching (BC) (#20570)

This commit is contained in:
Markus Thierolf 2025-04-18 17:01:46 +02:00 • committed by GitHub
parent e08016f6e9
commit 21b76d5627
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 714 additions and 407 deletions

View file

@ -72,15 +72,12 @@ const teslaloggerMiddleware = (req, res, next) => {
};
const shellyMiddleware = (req, res, next) => {
// simulate a shelly gen1 device api. implement power and energy
// simulate a shelly gen2 device api. implement power and energy
if (req.method === "GET" && req.originalUrl === "/shelly") {
res.end(JSON.stringify({ gen: 2 }));
} else if (req.originalUrl === "/rpc/Shelly.GetStatus") {
res.end(JSON.stringify({ model: "SNSW-001P16EU", gen: 2 }));
} else if (req.originalUrl === "/rpc/Switch.GetStatus?id=0") {
res.end(
JSON.stringify({
"switch:0": { apower: state.site.pv.power, aenergy: { total: state.site.pv.energy } },
})
);
JSON.stringify({ apower: state.site.pv.power, aenergy: { total: state.site.pv.energy } }));
} else {
next();
}