Skip to content

Commit

Permalink
added home.activate_absence_permanent
Browse files Browse the repository at this point in the history
  • Loading branch information
coreGreenberet committed Jan 23, 2021
1 parent 1243177 commit 5f1d7ab
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- API
- Rules
- Add async classes and methods for rules
- Home
- Added [activate_absence_permanent] method
- Devices
- [HMIP-DRSI1] (Switch Actuator for DIN rail mount – 1x channel)
- [HMIP-SRD] (Rain Sensor)
Expand Down Expand Up @@ -413,3 +415,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[HMIP-SRD]: https://github.com/coreGreenberet/homematicip-rest-api/issues/375
[HMIP-WRCC2]: https://github.com/coreGreenberet/homematicip-rest-api/issues/373
[HMIP-DRSI1]: https://github.com/coreGreenberet/homematicip-rest-api/issues/373
[activate_absence_permanent]: https://github.com/coreGreenberet/homematicip-rest-api/issues/357
10 changes: 10 additions & 0 deletions hmip_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ def main():
default=None,
type=int,
)
group.add_argument(
"--activate-absence-permanent",
dest="activate_absence_permanent",
action="store_true",
help="activates absence forever",
)
group.add_argument(
"--deactivate-absence",
action="store_true",
Expand Down Expand Up @@ -654,6 +660,10 @@ def main():
command_entered = True
home.activate_absence_with_duration(args.activate_absence)

if args.activate_absence_permanent:
command_entered = True
home.activate_absence_permanent()

if args.deactivate_absence:
command_entered = True
home.deactivate_absence()
Expand Down
3 changes: 3 additions & 0 deletions homematicip/aio/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ async def activate_absence_with_period(self, endtime):
*super().activate_absence_with_period(endtime)
)

async def activate_absence_permanent(self):
return await self._connection.api_call(*super().activate_absence_permanent())

async def deactivate_absence(self):
return await self._connection.api_call(*super().deactivate_absence())

Expand Down
5 changes: 5 additions & 0 deletions homematicip/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ def activate_absence_with_period(self, endtime: datetime):
"home/heating/activateAbsenceWithPeriod", json.dumps(data)
)

def activate_absence_permanent(self):
""" activates the absence forever
"""
return self._restCall("home/heating/activateAbsencePermanent")

def activate_absence_with_duration(self, duration: int):
""" activates the absence mode for a given time
Expand Down
17 changes: 17 additions & 0 deletions homematicip_demo/fake_cloud_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,23 @@ async def post_hmip_home_heating_activateAbsenceWithPeriod(

return web.json_response(None)

@validate_authorization
async def post_hmip_home_heating_activateAbsencePermanent(
self, request: web.Request
) -> web.Response:

self.data["home"]["functionalHomes"]["INDOOR_CLIMATE"][
"absenceEndTime"
] = "2100_12_31 23:59"
self.data["home"]["functionalHomes"]["INDOOR_CLIMATE"][
"absenceType"
] = "PERMANENT"
self.data["home"]["functionalHomes"]["INDOOR_CLIMATE"][
"ecoDuration"
] = "PERMANENT"

return web.json_response(None)

@validate_authorization
async def post_hmip_home_heating_deactivateAbsence(
self, request: web.Request
Expand Down
10 changes: 10 additions & 0 deletions tests/aio_tests/test_async_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ async def test_indoor_climate_home(no_ssl_fake_async_home: AsyncHome):
assert fh.absenceType == AbsenceType.PERIOD
assert fh.absenceEndTime == absence_end

await no_ssl_fake_async_home.activate_absence_permanent()

await no_ssl_fake_async_home.get_current_state()

assert fh.absenceType == AbsenceType.PERMANENT
assert fh.absenceEndTime == datetime.strptime(
"2100_12_31 23:59", "%Y_%m_%d %H:%M"
)
assert fh.ecoDuration == EcoDuration.PERMANENT

await no_ssl_fake_async_home.deactivate_absence()

await no_ssl_fake_async_home.get_current_state()
Expand Down
10 changes: 10 additions & 0 deletions tests/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ def test_indoor_climate_home(fake_home: Home):
assert fh.absenceType == AbsenceType.PERIOD
assert fh.absenceEndTime == absence_end

fake_home.activate_absence_permanent()

fake_home.get_current_state()

assert fh.absenceType == AbsenceType.PERMANENT
assert fh.absenceEndTime == datetime.strptime(
"2100_12_31 23:59", "%Y_%m_%d %H:%M"
)
assert fh.ecoDuration == EcoDuration.PERMANENT

fake_home.deactivate_absence()

fake_home.get_current_state()
Expand Down

0 comments on commit 5f1d7ab

Please sign in to comment.