core icon indicating copy to clipboard operation
core copied to clipboard

Improve AtlanticDomesticHotWaterProductionMBLComponent support in Overkiz

Open ALERTua opened this issue 2 years ago • 10 comments

Proposed change

  • Correctly determines Atlantic Water Heater based on controllable_name rather than just a widget, as the latter does not distinguish the Atlantic Water Heater functions.
  • Correctly selects eco, performance, away, and manual modes for Atlantic Water
  • Adds a number of binary_sensors, sensors, numbers for Atlantic Water Heater entity

The code was tested on Atlantic Steatite Cube WI-FI VM 150 S4CS 2400W.

Type of change

  • [ ] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [x] 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 #113219
  • This PR is related to issue: #113219
  • 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.
  • [ ] Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

ALERTua avatar Mar 25 '24 14:03 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 Mar 25 '24 14:03 home-assistant[bot]

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar Mar 25 '24 15:03 home-assistant[bot]

Thanks a lot for your contribution!

Please include only a single entity change per PR. Would be great if you can split up the binary_sensor, number, sensor and water_heater changes to separate PRs. The smaller PRs should get in fairly easy, the water heater might take a bit more time.

Done. Preparing separate PRs for binary_sensors, number and sensor

ALERTua avatar Mar 25 '24 15:03 ALERTua

Added separate pull requests: #114184, #114185, #114186

ALERTua avatar Mar 25 '24 15:03 ALERTua

Final checks are successful from my side. before: image after: image

ALERTua avatar Apr 08 '24 07:04 ALERTua

@iMicknl kind reminder

ALERTua avatar Apr 26 '24 10:04 ALERTua

Any news about this update? Maybe I'm just impatient, but it would be nice to get the automation working. Right now, we have to control the water heating with a smart plug if we want to heat water only during the cheapest hours. However, they tend to break quite quickly in this usage. Perhaps a 16A relay is too small for this use case. From my understanding (I'm not sure), utilizing the water heater's absence/away mode could be beneficial in this scenario.

sippe2 avatar May 07 '24 19:05 sippe2

Any news about this update? Maybe I'm just impatient, but it would be nice to get the automation working. Right now, we have to control the water heating with a smart plug if we want to heat water only during the cheapest hours. However, they tend to break quite quickly in this usage. Perhaps a 16A relay is too small for this use case. From my understanding (I'm not sure), utilizing the water heater's absence/away mode could be beneficial in this scenario.

I’m planning same usage here Waiting for this improvement to be merged

iperniaf avatar May 08 '24 19:05 iperniaf

Sorry I am on holidays and afk for some more weeks, so this would depend on another reviewer or wait a bit more..

iMicknl avatar May 09 '24 07:05 iMicknl

Hi @Tronix117 Can you please continue this review process Thx

iperniaf avatar May 09 '24 08:05 iperniaf

Hi @iMicknl

It seems that no one has wanted to review the written code. How could ALERTua proceed otherwise to get this feature implemented?

sippe2 avatar Jun 09 '24 18:06 sippe2

I will have a look soon. @iperniaf / @sippe2 have you tested this PR with your devices?

iMicknl avatar Jun 20 '24 20:06 iMicknl

I will have a look soon. @iperniaf / @sippe2 have you tested this PR with your devices?

I have not tested it. I’ve tried if there is any easy way, replacing python files on my devices but no luck

iperniaf avatar Jun 20 '24 22:06 iperniaf

I will have a look soon. @iperniaf / @sippe2 have you tested this PR with your devices?

@iMicknl I just tried it quickly but I had very limited time scope. Hopefully, I can do proper tests soon.

Atlantic_test12

@iperniaf Here is guide to create test environment: https://developers.home-assistant.io/docs/development_environment/ After cloning you can modify/add needed 3 files restart and make tests.

@ALERTua Could you send more tests to look? Does the absence mode also work? I suppose you have used your improvement a couple months so you may have a lot of test experience how your code works. :-)

sippe2 avatar Jun 21 '24 01:06 sippe2

@ALERTua Could you send more tests to look? Does the absence mode also work? I suppose you have used your improvement a couple months so you may have a lot of test experience how your code works. :-)

I did not use my improvements as my HA server runs on the release branch, so I am waiting for this PR to be released to use it thoroughly. I am unaware of how to use a commit instead of a release on a Supervised HA server hosted on a dedicated VM. I did not use the Away mode with my modifications, it will be fine for me for the Away mode not to work and to be fixed later, as I am a bit tired of this PR delay and just want the main goal of boiler profiles to work. I will try to go through setting up the development environment once again and give you a couple of screenshots, but as I am from Kyiv, Ukraine, I have 2 by 2 hours of electricity per day, and this PR is not a top priority in my daily routine.

ALERTua avatar Jun 21 '24 07:06 ALERTua

I have removed support for Away mode, as its implementation is not trivial: it cannot be just turned on and off, it needs a datetime range to activate, and I couldn't find out how to deactivate it. The same thing with turning off the device: it seems that there is no such thing in the API. After my recent changes, the device correctly displays and switches between Manual, Eco, and Boost modes. The actions are correctly displayed in the corresponding mobile application for the device and vice-versa. I can work on expanding the capabilities of the device, but I would like to do it in a separate PR, as even this one takes quite long to push. image image image image The PR is updated with the latest dev branch, tested, and ready to be merged.

ALERTua avatar Jun 21 '24 08:06 ALERTua

@ALERTua,

I am deeply sorry about the war and all the terrible things russia has done to your country. I think of you, the people of Ukraine, in my heart every day. Слава Україні!

I personally don't understand enough about how Home Assistant, Overkiz, and Atlantic's DHW work. I would like to find a way to turn off the water heater when the electricity price is very high and heat the water only when the price is low. In Finland, the price of electricity per kWh fluctuates a lot during the day. It can be just a few cents, but at worst, the price can rise up to a euro, and then there's the electricity transmission fee on top of that. Currently, I have solved the issue by using a separate smart plug to turn on the boiler at the right time, but these plugs only last a few months and then break so I need to buy and configure new one all the time. Do you have any ideas on how this could be done differently? I was hoping that the Absence mode would have been the answer to this problem, but it seems to be difficult to solve...

sippe2 avatar Jun 21 '24 11:06 sippe2

@sippe2 Thank you for your kind words

As of now, you can turn on the absence mode via the official CozyTouch mobile application. I have spent more than an hour playing with overkiz commands to enable or disable the Absence Mode, but alas, no luck:

  • sending setAbsenceMode off does not turn off the Absence Mode in the mobile application despite that the next current_state getter returns that the Abcence Mode is turned off. I cannot rely on this result, as I need firm confirmation that the official application also displays the state correctly.
  • sending setAbsenceEndDate (now_date) and then setAbsenceMode off does not help either.
  • sending setAbsenceStartDate (now_date), setAbsenceEndDate (future_date), then setAbsenceMode on or setAbsenceMode prog does not enable the Absence Mode in the official application, but correctly updates the dates and the current state in the overkiz API, so the problem is the same: I can rely on these commands only as soon as the mobile application correctly displays the results of these commands.

As soon as this PR is merged, I will try to find more time to experiment with the absence mode and create another PR with its implementation.

ALERTua avatar Jun 21 '24 12:06 ALERTua

@ALERTua , Thank you. I hope this absence mode issue will be resolved eventually. I've spent several hours trying to figure it out using your code examples, but haven't had any success. With my current skills, it seems unlikely that I find a clever solution. I'll keep banging my head against the wall, in case I accidentally come up with something useful to activate the absence mode. (Please, don't give up.) ;-)

sippe2 avatar Jun 21 '24 15:06 sippe2

Hi @ALERTua No worries about the away mode. I plan to setup a test env for me in August. if someone provides me the API doc, I can start studying it to try to find some ways of doing this

iperniaf avatar Jun 22 '24 23:06 iperniaf

Yesterday when I experimented with away mode I accidentally left my boiler in setAbsenceMode on, which did not display in the mobile application. In the morning I discovered I had zero showers left and the water was at room temperature. So I sat and played a bit more with the states and commands and decided to reintroduce the Away mode, as it appears to work. Also, I found the electrical consumption (which is either 2400W or 0W) and warm (40°C) water remaining extrapolation sensors. Alas, these sensors, along with the heating status sensor do not get properly updated after operations, and refreshHeatingStatus and refreshPowerHeatElectrical commands are needed to refresh them properly. As these command names are not in pyoverkiz, and @iMicknl is unavailable, I decided to leave this behavior as is, but it can be improved if these commands are sent after each operation change (mode, boost, away, temperature, number of showers change) to display the electrical consumption and heating status properly. Also, I fixed the bug with the heating status. image

ALERTua avatar Jun 23 '24 10:06 ALERTua

@ALERTua , Awesome! Great work. It seems that the secrets of Atlantic are beginning to be revealed. Thank you for persevering to turn this puzzle into a functional feature.

sippe2 avatar Jun 23 '24 16:06 sippe2

@ALERTua I am actually back and happy to have a look. Would you need these two constants/enums for this PR? I can add them quickly, no worries.

iMicknl avatar Jun 23 '24 20:06 iMicknl

@ALERTua I am actually back and happy to have a look. Would you need these two constants/enums for this PR? I can add them quickly, no worries.

To be clear, we are talking about https://github.com/home-assistant/core/pull/114178#issuecomment-2184939242 the refreshing of the sensors that do not refresh themselves too much. I am afraid I need more than just fields in pyoverkiz from you. I need a consultation regarding those refresh rates. If I just add a command call that refreshes the electrical consumption attribute and then a command call to refresh the heating status attribute, I will reach the 429 rate limit exceeded error even faster. I couldn't find a call that forces a refresh of "all" attributes, and, also, if I refresh the electrical consumption attribute right after I switch the operation mode and the heater starts to heat, the attribute still shows zero, so there should at least a one-second pause. I couldn't find any examples of such behavior and thought that this wouldn't be pretty. Can you suggest from your experience, how these matters should be handled?

ALERTua avatar Jun 24 '24 07:06 ALERTua

Hi @ALERTua ,

I finally managed to test it with my own Atlantic, and actually, the functions seem to work as you described in general.

Modes_are_ok

Same in app and seems to be working ok!

boost

However, I noticed a strange issue in the away mode that seems to cause an odd situation. When I switch from performance mode to away mode, the state information disappears completely or alternatively changes to unknown, and Home Assistant reports an error. The state does indeed change to absence mode in the app, so the away mode works in principle. After a while, the absence mode changed itself back to off mode.

away_mode_bug absence_in_app

I suppose that away mode actually works but there should be different "work mode" or "off state" or "something"...

sippe2 avatar Jun 26 '24 11:06 sippe2

yeah, about that: while in Away mode, the heater is off, but the entity does not support this state, at least I don't know how I can allow the entity to become OFF without allowing the user to try to switch the heater OFF. I don't see a problem with this, but I will accept any suggestions for improvement.

ALERTua avatar Jun 26 '24 11:06 ALERTua

yeah, about that: while in Away mode, the heater is off, but the entity does not support this state, at least I don't know how I can allow the entity to become OFF without allowing the user to try to switch the heater OFF. I don't see a problem with this, but I will accept any suggestions for improvement.

@ALERTua , I'm quite sure that with your experience with Atlantic, this puzzle will be solved sooner or later. :-)

sippe2 avatar Jun 26 '24 11:06 sippe2

Hi @iMicknl ,

I can confirm that the code works on my device as ALERTua described.

sippe2 avatar Jun 26 '24 11:06 sippe2