Skip to content

Commit

Permalink
Updates after testing with home assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperraemaekers committed Jul 12, 2024
1 parent 076d7a4 commit 25c535b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions weheat_backend_client/abstractions/auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC
from aiohttp import ClientResponse
from abc import ABC, abstractmethod
from aiohttp import ClientSession, ClientResponse


class AbstractAuth(ABC):
Expand Down
29 changes: 24 additions & 5 deletions weheat_backend_client/abstractions/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

class HeatPumpDiscovery:
@dataclass
class HeatPump:
class HeatPumpInfo:
uuid: str
name: str
household_name: str
model: str
sn : str
has_dhw: bool = False

@staticmethod
def discover(api_url: str, access_token: str) -> list[HeatPump]:
discovered_pumps = {}
def discover(api_url: str, access_token: str) -> list[HeatPumpInfo]:
discovered_pumps = []

config = Configuration(host=api_url, access_token=access_token)

Expand All @@ -23,6 +25,23 @@ def discover(api_url: str, access_token: str) -> list[HeatPump]:
response = HeatPumpApi(client).api_v1_heat_pumps_get_with_http_info()
if response.status_code == 200:
for pump in response.data:
discovered_pumps[pump.id] = pump.serial_number
model_string = "BlackBird P80 heat pump"
if pump.model == 1:
model_string = "BlackBird P60 heat pump"
elif pump.model == 2:
model_string = "Sparrow P60 heat pump"

dhw = False
if pump.dhw_type is not None and pump.dhw_type == 1:
dhw = True

discovered_pumps.append(
HeatPumpDiscovery.HeatPumpInfo(
uuid=pump.id,
name=pump.name,
model=model_string,
sn=pump.serial_number,
has_dhw=dhw,
)
)
return discovered_pumps

0 comments on commit 25c535b

Please sign in to comment.