Skip to content

Commit e81fa14

Browse files
committed
Fix get_config to send get_config command
Fixes the HomeAssistantClient.get_config method so it actually sends "get_config" rather than "get_states".
1 parent f5c1f56 commit e81fa14

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

hass_client/client.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ def handle_message(message: Message):
132132
else:
133133
self._loop.call_soon(cb_func, message["event"])
134134

135-
return await self.subscribe(handle_message, "subscribe_events", event_type=event_type)
135+
return await self.subscribe(
136+
handle_message, "subscribe_events", event_type=event_type
137+
)
136138

137139
async def subscribe_entities(
138140
self, cb_func: Callable[[EntityStateEvent], None], entity_ids: list[str]
@@ -155,7 +157,9 @@ def handle_message(message: Message):
155157
else:
156158
self._loop.call_soon(cb_func, message["event"])
157159

158-
return await self.subscribe(handle_message, "subscribe_entities", entity_ids=entity_ids)
160+
return await self.subscribe(
161+
handle_message, "subscribe_entities", entity_ids=entity_ids
162+
)
159163

160164
async def call_service(
161165
self,
@@ -189,7 +193,7 @@ async def get_states(self) -> list[State]:
189193

190194
async def get_config(self) -> list[Config]:
191195
"""Get dump of the current config in Home Assistant."""
192-
return await self.send_command("get_states")
196+
return await self.send_command("get_config")
193197

194198
async def get_services(self) -> dict[str, dict[str, Any]]:
195199
"""Get dump of the current services in Home Assistant."""
@@ -209,9 +213,13 @@ async def get_entity_registry(self) -> list[Entity]:
209213

210214
async def get_entity_registry_entry(self, entity_id: str) -> Entity:
211215
"""Get single entry from Entity Registry."""
212-
return await self.send_command("config/entity_registry/get", entity_id=entity_id)
216+
return await self.send_command(
217+
"config/entity_registry/get", entity_id=entity_id
218+
)
213219

214-
async def send_command(self, command: str, **kwargs: dict[str, Any]) -> CommandResultData:
220+
async def send_command(
221+
self, command: str, **kwargs: dict[str, Any]
222+
) -> CommandResultData:
215223
"""Send a command to the HA websocket and return response."""
216224
future: asyncio.Future[CommandResultData] = self._loop.create_future()
217225
if "message_id" in kwargs:
@@ -260,7 +268,9 @@ def remove_listener():
260268
if "subscribe" not in message_base["command"]:
261269
return
262270
unsub_command = message_base["command"].replace("subscribe", "unsubscribe")
263-
asyncio.create_task(self.send_command_no_wait(unsub_command, subscription=message_id))
271+
asyncio.create_task(
272+
self.send_command_no_wait(unsub_command, subscription=message_id)
273+
)
264274

265275
return remove_listener
266276

@@ -292,7 +302,9 @@ async def connect(self, ssl: SSLContext | bool | Fingerprint | None = True) -> N
292302
auth_result: AuthResultMessage = await self._client.receive_json()
293303
if auth_result["type"] != "auth_ok":
294304
await self._client.close()
295-
raise AuthenticationFailed(auth_result.get("message", "Authentication failed"))
305+
raise AuthenticationFailed(
306+
auth_result.get("message", "Authentication failed")
307+
)
296308
except (
297309
client_exceptions.WSServerHandshakeError,
298310
client_exceptions.ClientError,
@@ -370,7 +382,9 @@ def _handle_incoming_message(self, msg: Message) -> None:
370382
future = self._result_futures.get(msg["id"])
371383

372384
if future is None:
373-
LOGGER.debug("Received result for unknown message with ID: %s", msg["id"])
385+
LOGGER.debug(
386+
"Received result for unknown message with ID: %s", msg["id"]
387+
)
374388
return
375389

376390
if msg["success"]:

0 commit comments

Comments
 (0)