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

Adds Tado Child Lock support #135837

Draft
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

proohit
Copy link

@proohit proohit commented Jan 17, 2025

Proposed change

This PR adds support for tado child lock (https://support.tado.com/en/articles/4849684-what-is-child-lock).

Also bumps python-tado to 0.18.6 which introduced this feature api wise (https://github.com/wmalgadey/PyTado/releases/tag/0.18.6).

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 @proohit

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

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 January 17, 2025 10:16
@home-assistant
Copy link

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

Code owner commands

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

@proohit
Copy link
Author

proohit commented Jan 17, 2025

Hey,

this is my first contribution and I'm not yet warm with all the requirements.

The core functionality should be implemented, but there might be cases that I'm not aware of. Also, if I have some more time, I will look into testing and docs. If anyone is interested in helping out or advising, feel free :)

@erwindouna
Copy link
Contributor

Thanks for submitting your first PR! The Tado Connector is currently under a revamp, to be upgraded to a Data Update Coordinator: #134175. This PR is also completed. This will heavily impact the main structure of communicating with Tado.

How have you tested the child lock (other than going a version in the upstream)? Since this isn't released yet in the current PyTado library. I have recently added this particular code myself in the PyTado library. 😄
It will be released soon and when it does, I personally also want to include this in HA. It will once, the PyTado is scheduled for a new release and once the DUC PR is finalized.

@proohit
Copy link
Author

proohit commented Jan 17, 2025

@erwindouna Thanks for your feedback. I had no other way than using the upstream^^

@proohit
Copy link
Author

proohit commented Jan 17, 2025

@erwindouna Maybe this PR could assist you in that it already adds a SwitchEntity to a zone using the first zone device (I was heavily influenced by climate.py 😄 ), which you can build upon.

@erwindouna
Copy link
Contributor

It's great to see other people also wanting to contribute! If you'd like I can keep this open and once PyTado and DUC are ready, you want to integrate the child lock? :)

@proohit
Copy link
Author

proohit commented Jan 17, 2025

I looked into the DUC PR and I think the changes are a very welcome alteration in how Tado data is kept stored.

If you want, you can add it yourself. If this PR helps you, you can leave it open for reference, although I think you're perfectly capable of implementing it much better :D. I can help though if needed, as I am interested in that feature being added. Will leave the decision up to you.

Thanks for enhancing the integration!

@proohit
Copy link
Author

proohit commented Jan 26, 2025

@erwindouna happy to report that with 0.18.6 I have now adapted the switch to DUC and everything is working smoothly!

proohit added a commit to proohit/home-assistant.io that referenced this pull request Jan 26, 2025
Copy link
Contributor

@erwindouna erwindouna left a comment

Choose a reason for hiding this comment

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

Great additions, thanks @proohit! I have left the first initial comments. Also, please update the test cases, so that the child lock is also tested.

homeassistant/components/tado/switch.py Outdated Show resolved Hide resolved
homeassistant/components/tado/switch.py Show resolved Hide resolved
homeassistant/components/tado/switch.py Outdated Show resolved Hide resolved
@proohit
Copy link
Author

proohit commented Jan 27, 2025

@erwindouna Added all the requested changes. I'm not fully satisfied with the tests, because I wanted to patch the updated state gotten from get_device_info but unfortunately in the tests this resolved the switch state to unavailable. I've tried with a custom fixture and a custom dict

patch("homeassistant.components.tado.PyTado.interface.api.Tado.get_device_info",
           return_value={"shortSerialNo": "WR4", "childLockEnabled": True},
)

but both had the same result.

Only thing I tested now is if the child lock api endpoint is called with the correct boolean.

@proohit
Copy link
Author

proohit commented Jan 27, 2025

Also I think by updating some fixtures, I broke some snapshot tests. Do you know how to update them?

@erwindouna
Copy link
Contributor

Also I think by updating some fixtures, I broke some snapshot tests. Do you know how to update them?

By using --snapshot-update. Be careful though, you need to verify that the new snapshot really provides the new reality. Updating it for the sake of updating is not adding any value of thorough test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants