fix api integration quality baseline
This commit is contained in:
15
app/dependencies.py
Normal file
15
app/dependencies.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import HTTPException, Request, status
|
||||
|
||||
from app.ha.reader import HaReader
|
||||
|
||||
|
||||
def get_ha_reader(request: Request) -> HaReader:
|
||||
reader = getattr(request.app.state, "ha_reader", None)
|
||||
if not isinstance(reader, HaReader):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Home Assistant is not configured.",
|
||||
)
|
||||
return reader
|
||||
Reference in New Issue
Block a user