core icon indicating copy to clipboard operation
core copied to clipboard

Update overkiz Atlantic Water Heater away mode switching

Open ALERTua opened this issue 1 year ago • 2 comments

Breaking change

Proposed change

Based on #114184, changes the way the away mode is switched on for the Atlantic Water Heaters, setting setAbsenceStartDate and setAbsenceEndDate before switching on the away mode. Alas, the initial functionality with just switching the away mode on has some kind of rechecks on the Cozytouch server, and the away mode keeps getting switched off on the server side due to the start and end dates being incorrect (past dates). This change corrects this behavior, making the switch consistent with the Cozytouch mobile application behavior. The API uses two different away mode states: on and prog, but based on @sippe2 testing, those states have the exact functionality, so for the sake of consistency within the HA code, the on state is left to be used. This behavior may be changed if core maintainers wish so. Here are @sippe2 tests for on and prog away modes: image Image tl;dr: on and prog are the same, setAbsenceStartDate needs to be set beforehand with now or the future, setAbsenceEndDate needs to be set beforehand and to be in the future, only then on or prog away modes may be set. The way the API accepts setting dates is based on the original core:DateTimeState state for the DHW that returns a dict (like this {'day': 11, 'hour': 21, 'minute': 12, 'month': 7, 'second': 53, 'weekday': 3, 'year': 2024}), the dict is then passed as a start date, and then as an end date, but with year incremented by 1. The weekday seems to have no effect, and I didn't want to calculate the future date correct week day, but I can base all the dates on homeassistant dt_util and form those dictionaries from scratch based on datetime.now() and datetime.timedelta into the future if core maintainers wish so. In my recent tests I discovered that core:DateTimeState device state does NOT have a consistent current datetime. I have found that the datetime gets lost after power outages, so in order to correctly set away start and end dates, the setDateTime command should be called to set the core:DateTimeState state of the device to the current datetime before setting the away start and end dates. Also, changes the way to determine that the away mode is turned on by checking that the value is on or prog, which is consistent with the API and the mobile application. Also, the commands executor now accepts an optional argument refresh_afterwards, that allows sending multiple commands without refreshing after each one, and then finally refreshing afterward. This fixes the device briefly going 'unavailable' when sending multiple commands as in switching the away mode on.

Uses the new Overkiz API fields. Related PRs: https://github.com/iMicknl/python-overkiz-api/pull/1293 https://github.com/iMicknl/python-overkiz-api/pull/1294 If you are reading this while there are the hardcoded command names, I will update them to the pyoverkiz fields as soon as the PR above is released. The code was tested on Atlantic Steatite Cube WI-FI VM 150 S4CS 2400W.

The ongoing plan for this PR:

  • [x] pyoverkiz constants PR gets merged https://github.com/iMicknl/python-overkiz-api/pull/1293
  • [x] pyoverkiz constants PR gets merged https://github.com/iMicknl/python-overkiz-api/pull/1294
  • [x] pyoverkiz 1.13.14 gets into ha_core requirements via https://github.com/home-assistant/core/pull/122691
  • [x] This PR gets updated with the code that relies on 1.13.14
  • [x] This PR gets updated with the latest dev branch, gets its final tests, and switches to the non-draft mode
  • [x] Suggestions, fixes, retests
  • [x] This PR is approved
  • [ ] This PR is merged
  • [ ] This PR is released

Type of change

  • [ ] Dependency upgrade
  • [x] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [ ] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue: #114184
  • Link to documentation pull request:

Checklist

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] I have followed the perfect PR recommendations
  • [x] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • [ ] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [ ] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

ALERTua avatar Jul 11 '24 19:07 ALERTua

Hey there @imicknl, @vlebourl, @tetienne, @nyrodev, @tronix117, mind taking a look at this pull request as it has been labeled with an integration (overkiz) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of overkiz can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign overkiz Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

home-assistant[bot] avatar Jul 11 '24 19:07 home-assistant[bot]

Hi! Sorry to be bothering, I see the PR was approved last month, is it ready to be merged? :)

eliasto avatar Aug 23 '24 08:08 eliasto

@ALERTua There's a merge conflict, can you fix it?

emontnemery avatar Sep 25 '24 09:09 emontnemery

@ALERTua There's a merge conflict, can you fix it?

done

ALERTua avatar Sep 25 '24 09:09 ALERTua