-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated data fetch function, added all data fetch function, refactored
- Loading branch information
Showing
9 changed files
with
196 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
from ThermiaOnlineAPI.api.ThermiaAPI import ThermiaAPI | ||
from ThermiaOnlineAPI.model.HeatPump import ThermiaHeatPump | ||
|
||
class Thermia(): | ||
|
||
class Thermia: | ||
def __init__(self, username, password): | ||
self._username = username | ||
self._password = password | ||
|
||
self.api_interface = ThermiaAPI(username, password) | ||
self.connected = self.api_interface.authenticated | ||
self.heat_pumps = self.__get_heat_pumps() | ||
|
||
def __get_heat_pumps(self): | ||
self.heat_pumps = self.fetch_heat_pumps() | ||
|
||
def fetch_heat_pumps(self) -> list[ThermiaHeatPump]: | ||
devices = self.api_interface.get_devices() | ||
heat_pumps = [] | ||
|
||
for device in devices: | ||
heat_pumps.append(ThermiaHeatPump(device, self.api_interface)) | ||
|
||
return heat_pumps | ||
|
||
def update_data(self) -> None: | ||
for heat_pump in self.heat_pumps: | ||
heat_pump.update_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class AuthenticationException(Exception): | ||
""" | ||
Exception raised when the authentication fails. | ||
""" | ||
|
||
def __init__(self, message, status=None): | ||
|
||
super().__init__(message) | ||
|
||
self.status = status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class NetworkException(Exception): | ||
""" | ||
Exception raised when the network fails. | ||
""" | ||
|
||
def __init__(self, message, status=None): | ||
|
||
super().__init__(message) | ||
|
||
self.status = status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Thermia API Exceptions""" |
Oops, something went wrong.