@@ -169,6 +169,14 @@ void handlePostSettings() {
169169
170170void handleNotFound () { httpServer.send (404 , " text/html" , " <h1>404: Not found</h1>" ); }
171171
172+ void handlePin0Indicator () {
173+ String pinIndicator = is_pin0_on
174+ ? R"( <div class="pin-indicator pin-active" hx-get="/data/pin0indicator" hx-trigger="load, every 10s" hx-swap="outerHTML"></div>)"
175+ : R"( <div class="pin-indicator" hx-get="/data/pin0indicator" hx-trigger="load, every 10s" hx-swap="outerHTML"></div>)" ;
176+
177+ httpServer.send (200 , " text/html" , pinIndicator);
178+ }
179+
172180bool switch_pin (uint8_t pin) {
173181 bool is_on;
174182 auto min_battery = *std::min_element (battery_charge_history.begin (), battery_charge_history.end ());
@@ -247,6 +255,7 @@ void setup() {
247255 httpServer.on (" /data/plantPower" , HTTP_GET, handlePlantPower);
248256 httpServer.on (" /data/powerMeterActivePower" , HTTP_GET, handlePowerMeterActivePower);
249257 httpServer.on (" /data/firmwareVersion" , HTTP_GET, handleFirmwareVersion);
258+ httpServer.on (" /data/pin0indicator" , HTTP_GET, handlePin0Indicator);
250259 httpServer.on (" /settings" , HTTP_GET, handleSettings);
251260 httpServer.on (" /settings" , HTTP_POST, handlePostSettings);
252261 httpServer.onNotFound (handleNotFound);
0 commit comments