diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41f0f9a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*/__pycache__/ +*.pyc diff --git a/custom_components/bluetti-bt/__init__.py b/custom_components/bluetti_bt/__init__.py similarity index 91% rename from custom_components/bluetti-bt/__init__.py rename to custom_components/bluetti_bt/__init__.py index b7aa424..ec16b3c 100644 --- a/custom_components/bluetti-bt/__init__.py +++ b/custom_components/bluetti_bt/__init__.py @@ -16,9 +16,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Bluetti Powerstation from a config entry.""" address = entry.data.get(CONF_ADDRESS) - + if address is None: return False - _LOGGER.error(f"Device address: {address}") + _LOGGER.error("Device address: %s", address) return True diff --git a/custom_components/bluetti-bt/config_flow.py b/custom_components/bluetti_bt/config_flow.py similarity index 94% rename from custom_components/bluetti-bt/config_flow.py rename to custom_components/bluetti_bt/config_flow.py index 201e729..8f46d3b 100644 --- a/custom_components/bluetti-bt/config_flow.py +++ b/custom_components/bluetti_bt/config_flow.py @@ -7,7 +7,7 @@ import logging import voluptuous as vol from homeassistant import config_entries -from homeassistant.components import ( +from homeassistant.components.bluetooth import ( BluetoothServiceInfoBleak, async_discovered_service_info, ) @@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__) class BluettiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Handle config flow for Bluetti BT devices.""" - + def __init__(self) -> None: _LOGGER.info("Initialize config flow") self._discovery_info: BluetoothServiceInfoBleak | None = None @@ -34,11 +34,14 @@ class BluettiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(discovery_info.address) self._abort_if_unique_id_configured() self._discovery_info = discovery_info + self.context["title_placeholders"] = { + "name": discovery_info.name + } return await self.async_step_user() async def async_step_user(self, user_input: dict[str, Any] | None = None) -> FlowResult: """Handle user input.""" - + if user_input is not None: address = user_input[CONF_ADDRESS] discovery_info = self._discovered_devices[address] diff --git a/custom_components/bluetti-bt/const.py b/custom_components/bluetti_bt/const.py similarity index 69% rename from custom_components/bluetti-bt/const.py rename to custom_components/bluetti_bt/const.py index 978dd05..562fba7 100644 --- a/custom_components/bluetti-bt/const.py +++ b/custom_components/bluetti_bt/const.py @@ -1,3 +1,3 @@ """Constants for the Bluetti BT integration.""" -DOMAIN = "bluetti-bt" +DOMAIN = "bluetti_bt" diff --git a/custom_components/bluetti-bt/manifest.json b/custom_components/bluetti_bt/manifest.json similarity index 95% rename from custom_components/bluetti-bt/manifest.json rename to custom_components/bluetti_bt/manifest.json index 2002cb1..4529308 100644 --- a/custom_components/bluetti-bt/manifest.json +++ b/custom_components/bluetti_bt/manifest.json @@ -1,5 +1,5 @@ { - "domain": "bluetti-bt", + "domain": "bluetti_bt", "name": "Bluetti BT", "codeowners": ["@Patrick762"], "config_flow": true,