Skip to content

Commit

Permalink
Add window_open to heating (#189)
Browse files Browse the repository at this point in the history
* Add window_open to heating + remove redundant validation

* Add back

* Fix lint

* Undo
  • Loading branch information
inverse authored Jan 21, 2023
1 parent 61c1f1c commit 8a3903c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
9 changes: 7 additions & 2 deletions iolite_client/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ def __init__(

class Heating(Entity):
def __init__(
self, identifier: str, name: str, current_temp: float, target_temp: float
self,
identifier: str,
name: str,
current_temp: float,
target_temp: float,
window_open: bool,
):
super().__init__(identifier, name)
self.current_temp = current_temp
self.target_temp = target_temp
self.window_open = window_open


class Room(Entity):
Expand All @@ -73,7 +79,6 @@ def add_device(self, device: Device):
raise Exception(
f"Trying to add device to wrong room {device.place_identifier} != {self.identifier}"
)

self.devices[device.identifier] = device

def has_device(self, device: Device) -> bool:
Expand Down
1 change: 1 addition & 0 deletions iolite_client/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def create_heating(payload: dict) -> Heating:
payload["name"],
payload["currentTemperature"],
payload["targetTemperature"],
payload["windowOpen"],
)


Expand Down
4 changes: 3 additions & 1 deletion test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def setUp(self) -> None:
self.bedroom_switch = Switch(
"2", "Bedroom Switch", self.bedroom.identifier, "Generic"
)
self.bedroom_heating = Heating(self.bedroom.identifier, "Bedroom", 10, 20)
self.bedroom_heating = Heating(
self.bedroom.identifier, "Bedroom", 10, 20, False
)
self.discovered = Discovered()

def test_switch_without_room_is_unmapped(self):
Expand Down
4 changes: 3 additions & 1 deletion test/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def setUp(self) -> None:
"Normal",
0.0,
)
self.bedroom_heating = Heating(self.bedroom.identifier, "Bedroom", 20.0, 21.5)
self.bedroom_heating = Heating(
self.bedroom.identifier, "Bedroom", 20.0, 21.5, False
)

def test_empty_room(self):
self.assertEqual(0, len(self.bedroom.devices))
Expand Down
4 changes: 1 addition & 3 deletions test/test_oauth_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def test_get_sid_expired_access_token(self):

@freeze_time("2021-01-01 00:00:00")
def test_invalid_token_refresh(self):

token = self._get_token(datetime.datetime(2021, 1, 1, 0, 0, 1))
self.mock_oauth_storage.fetch_access_token.return_value = token

Expand All @@ -139,7 +138,7 @@ def _get_token(date_time: datetime.datetime) -> dict:


class AsyncOAuthWrapperTest(unittest.TestCase):
def setUp(self) -> None:
async def asyncSetUp(self) -> None:
self.mock_async_oauth_handler = Mock()
self.mock_async_oauth_storage = Mock()
self.async_oauth_wrapper = AsyncOAuthWrapper(
Expand Down Expand Up @@ -175,7 +174,6 @@ async def test_get_sid_expired_access_token(self):
@pytest.mark.asyncio
@freeze_time("2021-01-01 00:00:00")
async def test_invalid_token_refresh(self):

token = self._get_token(datetime.datetime(2021, 1, 1, 0, 0, 1))
self.mock_async_oauth_storage.fetch_access_token.return_value = token

Expand Down

0 comments on commit 8a3903c

Please sign in to comment.