Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use temperature of current preset when set fritz HVAC mode to HEAT #126044

Merged
merged 5 commits into from
Sep 30, 2024

Conversation

naruxde
Copy link
Contributor

@naruxde naruxde commented Sep 16, 2024

Breaking change

Proposed change

I use the FRITZ! DECT 302 thermostats on my heaters. In the Fritz! Box is a heating plan stored, which sets the temperature to COMFORT or ECO at certain times of the day. If I switch off the heating HVACMode.OFF via Home Assistant and turn it on again, the COMFORT temperature is always set, although the schedule for ECO is still active.

This change is intended to use the ECO temperature when switching on, if the schedule for ECO is still active, otherwise the COMFORT temperature.

Type of change

  • Dependency upgrade
  • 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

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • 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:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @naruxde

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

Hey there @mib1185, @flabbamann, mind taking a look at this pull request as it has been labeled with an integration (fritzbox) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of fritzbox 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 fritzbox 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.

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @naruxde

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@naruxde naruxde marked this pull request as ready for review September 16, 2024 11:49
@naruxde naruxde requested a review from mib1185 as a code owner September 16, 2024 11:49
Copy link
Contributor

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @naruxde

thanks for this contribution 👍
Besides the small comment from my side, the test fails - please check this. Don't hesitate to call for help if needed 😉

regards,
Michael

tests/components/fritzbox/test_climate.py Outdated Show resolved Hide resolved
@home-assistant
Copy link

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

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft September 16, 2024 13:46
@naruxde naruxde force-pushed the fritz-hvac-preset-mode branch from 4d67742 to 5df75de Compare September 16, 2024 14:05
@naruxde
Copy link
Contributor Author

naruxde commented Sep 16, 2024

Hi @mib1185!

I'm really sorry about what always went wrong 😖. I had even, before the push, made a pytest with call(17) on my system to see if it really fails.

@naruxde naruxde marked this pull request as ready for review September 16, 2024 14:16
@home-assistant home-assistant bot requested a review from mib1185 September 16, 2024 14:16
@home-assistant home-assistant bot dismissed stale reviews from themself September 16, 2024 14:16

Stale

Copy link
Contributor

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we now have a regression with tests test_set_temperature_mode_heat and test_set_hvac_mode_heat 🧐
i've not checked the code yet in detail, so would be grate if you could have a look first.

@home-assistant home-assistant bot marked this pull request as draft September 16, 2024 14:33
@naruxde
Copy link
Contributor Author

naruxde commented Sep 16, 2024

Yes, I'm just looking at that. We have with the FritzDeviceClimateMock a comfort_temperature = 22.0 and an eco_temperature = 16.0. Since nextchange_temperature = 22.0, value_scheduled_preset assumes that we are in PRESET_ECO.

So we would have to change nextchange_temperature in the FritzDeviceClimateMock class if we want to be in PRESET_COMFORT or adjust the value in the old test_set_hvac_mode_heat and remove it from the new test_set_hvac_mode_heat_eco.

We then generally only have the problem if eco and comfort are set to the same values in the Fritzbox, which mode should we use in Home Assistant. 🤔 - Currently it would be PRESET_ECO, which is not really wrong 😆

@naruxde
Copy link
Contributor Author

naruxde commented Sep 16, 2024

I pushed a commit as a suggestion for changing the tests. But maybe you have other ideas 🙂

@naruxde naruxde force-pushed the fritz-hvac-preset-mode branch from ba11dda to 8eb015f Compare September 16, 2024 15:27
@naruxde naruxde marked this pull request as ready for review September 16, 2024 15:27
@home-assistant home-assistant bot requested a review from mib1185 September 16, 2024 15:27
@naruxde naruxde force-pushed the fritz-hvac-preset-mode branch from 8eb015f to 6992bfb Compare September 16, 2024 15:36
Copy link
Contributor

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using value_scheduled_preset is the wrong approach, since it intention was another. It will always return "eco mode", if nextchange_temperature is not the eco_temperature, even when nextchange_temperature is 128 (or 255) (which means not set)

@home-assistant home-assistant bot marked this pull request as draft September 16, 2024 15:41
@mib1185
Copy link
Contributor

mib1185 commented Sep 18, 2024

please avoid rebase + force-push. this makes hard to get what has changed since last review, thx 👍

@naruxde
Copy link
Contributor Author

naruxde commented Sep 18, 2024

I just reset the change from the test in the test_set_temperature_mode_heat function. This is also part of PR #126072, if I understand correctly.

@mib1185
Copy link
Contributor

mib1185 commented Sep 20, 2024

Hi @naruxde
now as #126072 has been merged, you need to rebase your branch to latest dev (yes, in this case its ok, as soon as it is only a rebase, without code changes 😉) and go ahead with your PR, thx 👍

naruxde and others added 3 commits September 20, 2024 12:29
If the HVAC mode of the Fritzbox thermostats changes from `HVACMode.OFF`
to `HVAMode.HEAT`, the current preset (COMFORT / ECO) should be
observed. Depending on the status of the current preset, the set
temperature of comfort / eco is set as the new temperature.
The current_preset parameter allows the mock to be set to an active
preset. When setting HVACMode.HEAT, the respective temperature of the
ECO/COMFORT preset should be set.
@naruxde naruxde force-pushed the fritz-hvac-preset-mode branch from e5422dd to c5b7a5d Compare September 20, 2024 11:05
@naruxde
Copy link
Contributor Author

naruxde commented Sep 20, 2024

Hi @mib1185!

I hope that worked. I removed my tests and extended your new test with a current_preset parameter. I hope that was okay that I didn't insert a new test like before.

Copy link
Contributor

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @naruxde

I thought about it again and unfortunately came to the conclusion, that all the "next change " sensors needs to be fixed. The api returns the comfort temperature as next temperature, when there is no scheduler configured. The only way to detect if a scheduler is configured, is to check the next change time - if it is 0, than there is no scheduler, else it contains a valid future timestamp. I'm already working on a further PR to fix this. Afterwards we should really be able to go ahead with your PR.

thx for your patients 👍

@naruxde
Copy link
Contributor Author

naruxde commented Sep 21, 2024

Hi @mib1185!

Improvements are always good! I would also have no problem with it if you integrate the "hack" from this PR directly into your PR, which maybe results in a better solution. What ever you like most.

I look forward to it when the problem described above is solved, gladly also with a better solution than this 😆.

Copy link
Contributor

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @naruxde
we're close to get this ready and no, i won't put this into some of my PRs, because it is your contribution 😉
Please apply the following comments, thx 👍

homeassistant/components/fritzbox/climate.py Show resolved Hide resolved
homeassistant/components/fritzbox/climate.py Outdated Show resolved Hide resolved
tests/components/fritzbox/test_climate.py Outdated Show resolved Hide resolved
tests/components/fritzbox/test_climate.py Outdated Show resolved Hide resolved
To distinguish which temperature should be used when setting the
`HVAMode.HEAT`, `value_schedules_preset` is now used again, which has
been updated since the first commit. If no schedule is active, the
comfort_temperature is used. Otherwise, the respective temperature of
the current preset.

Co-authored-by: Michael <[email protected]>
Copy link
Contributor

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to click on "Ready to review" (#126044 (comment)) 😉

@naruxde naruxde marked this pull request as ready for review September 30, 2024 14:02
@home-assistant home-assistant bot requested a review from mib1185 September 30, 2024 14:02
@naruxde
Copy link
Contributor Author

naruxde commented Sep 30, 2024

Had to test locally 😋

Copy link
Contributor

@mib1185 mib1185 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx @naruxde 👍

@mib1185 mib1185 merged commit 7493107 into home-assistant:dev Sep 30, 2024
30 checks passed
KoBOLL pushed a commit to DevPocket/homeassistant-core that referenced this pull request Oct 1, 2024
…Fritz!Smarthome (home-assistant#126044)

* Use temperature of current preset when set fritz HVAC mode to HEAT

If the HVAC mode of the Fritzbox thermostats changes from `HVACMode.OFF`
to `HVAMode.HEAT`, the current preset (COMFORT / ECO) should be
observed. Depending on the status of the current preset, the set
temperature of comfort / eco is set as the new temperature.

* fixup do not use value_scheduled_preset

Co-authored-by: Michael <[email protected]>

* Add current_preset value to test_set_hvac_mode

The current_preset parameter allows the mock to be set to an active
preset. When setting HVACMode.HEAT, the respective temperature of the
ECO/COMFORT preset should be set.

* fixup Use the updated value_scheduled_preset function

To distinguish which temperature should be used when setting the
`HVAMode.HEAT`, `value_schedules_preset` is now used again, which has
been updated since the first commit. If no schedule is active, the
comfort_temperature is used. Otherwise, the respective temperature of
the current preset.

Co-authored-by: Michael <[email protected]>

---------

Co-authored-by: Michael <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants