@@ -683,6 +683,8 @@ void handleStatusPost(MongooseHttpServerRequest *request, MongooseHttpServerResp
683683 DeserializationError error = deserializeJson (doc, body);
684684 if (!error)
685685 {
686+ bool send_event = true ;
687+
686688 if (doc.containsKey (" voltage" ))
687689 {
688690 double volts = doc[" voltage" ];
@@ -699,29 +701,36 @@ void handleStatusPost(MongooseHttpServerRequest *request, MongooseHttpServerResp
699701 solar = doc[" solar" ];
700702 DBUGF (" solar:%dW" , solar);
701703 divert.update_state ();
704+ send_event = false ; // Divert sends the event so no need to send here
702705 }
703706 else if (doc.containsKey (" grid_ie" )) {
704707 grid_ie = doc[" grid_ie" ];
705708 DBUGF (" grid:%dW" , grid_ie);
706709 divert.update_state ();
710+ send_event = false ; // Divert sends the event so no need to send here
707711 }
708712 if (doc.containsKey (" battery_level" )) {
709713 double vehicle_soc = doc[" battery_level" ];
710714 DBUGF (" vehicle_soc:%d%%" , vehicle_soc);
711715 evse.setVehicleStateOfCharge (vehicle_soc);
716+ doc[" vehicle_state_update" ] = 0 ;
712717 }
713718 if (doc.containsKey (" battery_range" )) {
714719 double vehicle_range = doc[" battery_range" ];
715720 DBUGF (" vehicle_range:%dKM" , vehicle_range);
716721 evse.setVehicleRange (vehicle_range);
722+ doc[" vehicle_state_update" ] = 0 ;
717723 }
718724 if (doc.containsKey (" time_to_full_charge" )){
719725 double vehicle_eta = doc[" time_to_full_charge" ];
720726 DBUGF (" vehicle_eta:%d" , vehicle_eta);
721- evse.setVehicleEta (vehicle_eta);
727+ evse.setVehicleEta (vehicle_eta);
728+ doc[" vehicle_state_update" ] = 0 ;
722729 }
723730 // send back new value to clients
724- event_send (doc);
731+ if (send_event) {
732+ event_send (doc);
733+ }
725734
726735 response->setCode (200 );
727736 serializeJson (doc, *response);
@@ -733,7 +742,7 @@ void handleStatusPost(MongooseHttpServerRequest *request, MongooseHttpServerResp
733742
734743
735744void
736- handleStatus (MongooseHttpServerRequest *request)
745+ handleStatus (MongooseHttpServerRequest *request)
737746{
738747
739748 MongooseHttpServerResponseStream *response;
0 commit comments