Skip to content

Instantly share code, notes, and snippets.

@ALERTua
Created December 1, 2025 10:57
Show Gist options
  • Select an option

  • Save ALERTua/ad3882b2e190c57444c9b93007c3222b to your computer and use it in GitHub Desktop.

Select an option

Save ALERTua/ad3882b2e190c57444c9b93007c3222b to your computer and use it in GitHub Desktop.
diff --git c/custom_components/beszel-api/__init__.py i/custom_components/beszel-api/__init__.py
index f22e929..d844feb 100644
--- c/custom_components/beszel-api/__init__.py
+++ i/custom_components/beszel-api/__init__.py
@@ -10,8 +10,8 @@ async def async_setup_entry(hass, entry):
hass.data.setdefault(DOMAIN, {})
url = entry.data[CONF_URL]
- username = entry.data[CONF_USERNAME]
- password = entry.data[CONF_PASSWORD]
+ username = entry.data.get(CONF_USERNAME, None)
+ password = entry.data.get(CONF_PASSWORD, None)
client = BeszelApiClient(url, username, password)
async def async_update_data():
diff --git c/custom_components/beszel-api/api.py i/custom_components/beszel-api/api.py
index ffaf522..7ce6a4b 100644
--- c/custom_components/beszel-api/api.py
+++ i/custom_components/beszel-api/api.py
@@ -4,7 +4,7 @@ import logging
LOGGER = logging.getLogger(__name__)
class BeszelApiClient:
- def __init__(self, url, username, password):
+ def __init__(self, url, username: str | None = None, password: str | None = None):
self._url = url.rstrip("/")
self._username = username
self._password = password
@@ -15,7 +15,11 @@ class BeszelApiClient:
if self._client is None:
try:
self._client = PocketBase(self._url)
- self._client.collection("users").auth_with_password(self._username, self._password)
+ if self._username and self._password:
+ self._client.collection("users").auth_with_password(
+ self._username,
+ self._password,
+ )
except Exception as e:
LOGGER.error(f"Failed to initialize PocketBase client: {e}")
raise
diff --git c/custom_components/beszel-api/config_flow.py i/custom_components/beszel-api/config_flow.py
index e3b6294..22b51bc 100644
--- c/custom_components/beszel-api/config_flow.py
+++ i/custom_components/beszel-api/config_flow.py
@@ -16,8 +16,8 @@ class BeszelConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user",
data_schema=vol.Schema({
vol.Required(CONF_URL): str,
- vol.Required(CONF_USERNAME): str,
- vol.Required(CONF_PASSWORD): str,
+ vol.Optional(CONF_USERNAME): str,
+ vol.Optional(CONF_PASSWORD): str,
}),
errors=errors,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment