From 7fe2d04d315d8e6a63e7a7914566406e2ff749cf Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 1 Sep 2022 12:29:19 -0600 Subject: [PATCH] fix: add removal of RouteRequest when calling ReleaseRoute --- .../Routing/IRoutingInputsExtensions.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs index 2dbf895a..bd5aff73 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs @@ -105,6 +105,17 @@ namespace PepperDash.Essentials.Core /// public static void ReleaseRoute(this IRoutingSink destination) { + RouteRequest existingRequest; + + if (RouteRequests.TryGetValue(destination.Key, out existingRequest) && destination is IWarmingCooling) + { + var coolingDevice = destination as IWarmingCooling; + + coolingDevice.IsCoolingDownFeedback.OutputChange -= existingRequest.HandleCooldown; + } + + RouteRequests.Remove(destination.Key); + var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination); if (current != null) {