From 4d690b9e5d9a240fd771e35adc7fc021afec8676 Mon Sep 17 00:00:00 2001 From: Jesse Stoltz Date: Fri, 28 Jun 2024 18:28:44 -0500 Subject: [PATCH 1/3] Try fixing an issue with loading yaml when adding a dwains dash blueprint --- custom_components/dwains_dashboard/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/dwains_dashboard/__init__.py b/custom_components/dwains_dashboard/__init__.py index 9ded4f04..856ec9a1 100755 --- a/custom_components/dwains_dashboard/__init__.py +++ b/custom_components/dwains_dashboard/__init__.py @@ -249,7 +249,8 @@ async def ws_handle_install_blueprint( """Handle save new blueprint.""" #filecontent = json.loads(msg["yamlCode"]) - filecontent = yaml.safe_load(json.loads(msg["yamlCode"])) + yaml_string = json.dumps(msg["yamlCode"]) + filecontent = yaml.safe_load(yaml_string) #_LOGGER.warning(filecontent) From 640fc473bdc4b91d3a95e37396279b4c470901de Mon Sep 17 00:00:00 2001 From: Jesse Stoltz Date: Fri, 28 Jun 2024 18:37:31 -0500 Subject: [PATCH 2/3] Try again --- custom_components/dwains_dashboard/__init__.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/custom_components/dwains_dashboard/__init__.py b/custom_components/dwains_dashboard/__init__.py index 856ec9a1..8620907e 100755 --- a/custom_components/dwains_dashboard/__init__.py +++ b/custom_components/dwains_dashboard/__init__.py @@ -236,6 +236,8 @@ def websocket_get_blueprints( #install_blueprint +import yaml + @websocket_api.websocket_command( { vol.Required("type"): "dwains_dashboard/install_blueprint", @@ -247,12 +249,8 @@ async def ws_handle_install_blueprint( hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict ) -> None: """Handle save new blueprint.""" - - #filecontent = json.loads(msg["yamlCode"]) - yaml_string = json.dumps(msg["yamlCode"]) - filecontent = yaml.safe_load(yaml_string) - #_LOGGER.warning(filecontent) + filecontent = yaml.safe_load(msg["yamlCode"]) if not filecontent.get("blueprint"): _LOGGER.warning('no blueprint data') @@ -300,9 +298,6 @@ async def ws_handle_install_blueprint( with open(hass.config.path("dwains-dashboard/blueprints/"+filename), 'w') as f: yaml.dump(filecontent, f, default_flow_style=False, sort_keys=False) - #reload_configuration(hass) - - connection.send_result( msg["id"], { @@ -312,6 +307,7 @@ async def ws_handle_install_blueprint( + #delete_blueprint @websocket_api.websocket_command( { From 3fc4b4ae03d4762a417050a8ba95e84b7200f32f Mon Sep 17 00:00:00 2001 From: Jesse Stoltz Date: Fri, 28 Jun 2024 18:41:26 -0500 Subject: [PATCH 3/3] remove non-needed import --- custom_components/dwains_dashboard/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom_components/dwains_dashboard/__init__.py b/custom_components/dwains_dashboard/__init__.py index 8620907e..b221d7d3 100755 --- a/custom_components/dwains_dashboard/__init__.py +++ b/custom_components/dwains_dashboard/__init__.py @@ -236,8 +236,6 @@ def websocket_get_blueprints( #install_blueprint -import yaml - @websocket_api.websocket_command( { vol.Required("type"): "dwains_dashboard/install_blueprint",