diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index c224990319..d995614c2a 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -281,8 +281,11 @@ class EsphomeLogsHandler(EsphomeCommandWebSocket): class EsphomeRenameHandler(EsphomeCommandWebSocket): + old_name: str + def build_command(self, json_message): config_file = settings.rel_path(json_message["configuration"]) + self.old_name = json_message["configuration"] return [ "esphome", "--dashboard", @@ -291,6 +294,15 @@ class EsphomeRenameHandler(EsphomeCommandWebSocket): json_message["newName"], ] + def _proc_on_exit(self, returncode): + super()._proc_on_exit(returncode) + + if returncode != 0: + return + + # Remove the old ping result from the cache + PING_RESULT.pop(self.old_name, None) + class EsphomeUploadHandler(EsphomeCommandWebSocket): def build_command(self, json_message): @@ -859,6 +871,9 @@ class DeleteRequestHandler(BaseHandler): if build_folder is not None: shutil.rmtree(build_folder, os.path.join(trash_path, name)) + # Remove the old ping result from the cache + PING_RESULT.pop(configuration, None) + class UndoDeleteRequestHandler(BaseHandler): @authenticated