From 6849c805046ec66b8e955badf8c6a976169c7a15 Mon Sep 17 00:00:00 2001 From: Daniel Hofer Date: Sun, 13 Feb 2022 10:48:58 +0100 Subject: [PATCH] ensure port is closed when integration unloaded --- README.md | 2 ++ custom_components/bmstools/__init__.py | 4 ++++ custom_components/bmstools/manifest.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a47df7b..486525b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This integration is based on the BMS Tools project by Eric Poulsen: https://gitl A config flow is available that allows selecting the serial port of the connected BMS and assigning a serial number to connect multiple BMS.
Bluetooth is not supported (yet) by the underlying library. +Installable via HACS as custom repository ([Guide](https://codingcyclist.medium.com/how-to-install-any-custom-component-from-github-in-less-than-5-minutes-ad84e6dc56ff)). + # Currently supported BMS - JBD / Overkill Solar diff --git a/custom_components/bmstools/__init__.py b/custom_components/bmstools/__init__.py index ad81747..78678bd 100644 --- a/custom_components/bmstools/__init__.py +++ b/custom_components/bmstools/__init__.py @@ -94,6 +94,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) + # Ensure that client is closed + client: JBD = hass.data[DOMAIN][entry.entry_id][HASS_DATA_CLIENT] + client.close() + if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) diff --git a/custom_components/bmstools/manifest.json b/custom_components/bmstools/manifest.json index fe3fd72..83ed3df 100644 --- a/custom_components/bmstools/manifest.json +++ b/custom_components/bmstools/manifest.json @@ -1,7 +1,7 @@ { "domain": "bmstools", "name": "BMS Tools", - "version": "1.0.0-rc2", + "version": "1.0.0-rc3", "config_flow": true, "documentation": "https://github.com/ElD4n1/home-assistant-bms-tools-integration", "issue_tracker": "https://github.com/ElD4n1/home-assistant-bms-tools-integration/issues",