chore: fix e2e shelly mock (#20833)

This commit is contained in:
Michael Geers 2025-04-24 15:22:06 +02:00 • committed by GitHub
parent ef0a12d9a4
commit f0547b17a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -72,12 +72,15 @@ const teslaloggerMiddleware = (req, res, next) => {
};
const shellyMiddleware = (req, res, next) => {
// simulate a shelly gen2 device api. implement power and energy
if (req.method === "GET" && req.originalUrl === "/shelly") {
res.end(JSON.stringify({ model: "SNSW-001P16EU", gen: 2 }));
// simulate a shelly gen2 switch device api. implement power and energy
if (req.originalUrl === "/shelly") {
res.end(JSON.stringify({ gen: 2 }));
} else if (req.originalUrl === "/rpc/Shelly.ListMethods") {
res.end(JSON.stringify({ methods: ["Switch.GetStatus"] }));
} else if (req.originalUrl === "/rpc/Switch.GetStatus?id=0") {
res.end(
JSON.stringify({ 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();
}