Skip to content

Add support for viomi.waterheater.e1 devices - #834

Open
Zuz666 wants to merge 4 commits into
rytilahti:masterfrom
Zuz666:master
Open

Add support for viomi.waterheater.e1 devices#834
Zuz666 wants to merge 4 commits into
rytilahti:masterfrom
Zuz666:master

Conversation

@Zuz666

@Zuz666 Zuz666 commented Oct 11, 2020

Copy link
Copy Markdown
Contributor

Just added basic support for 'Viomi Electric Water Heater' devices (viomi.waterheater.e1*): power on/off + status (retrieve properties). Fully tested on real device, works fine.

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the PR! A brief initial review: please add an example response, follow the python naming conventions (foo_bar instead of camelcased fooBar). The property names should be descriptive instead of using the naming used by the protocol itself.

Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
@Zuz666

Zuz666 commented Oct 17, 2020

Copy link
Copy Markdown
Contributor Author

@rytilahti Thanks for great code review! I will make the code better as you request.

@makp0

makp0 commented Oct 3, 2021

Copy link
Copy Markdown

@Zuz666 , any progress on this pr? 🙂

@Zuz666 Zuz666 changed the title Initial support for viomi.waterheater.e1 devices Add support for viomi.waterheater.e1 devices Nov 5, 2021
@Zuz666

Zuz666 commented Nov 5, 2021

Copy link
Copy Markdown
Contributor Author

@Zuz666 , any progress on this pr? 🙂

@rytilahti, yep, just check the latest commits!
Fully tested on real device, works fine.

@Zuz666
Zuz666 requested a review from rytilahti November 5, 2021 10:19

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the update! I added a couple of more comments. Could you also do the following:

  • Add an entry to README.md
  • Move the code to be under miio/integrations/heater/viomiwaterheater/ - there are other heaters so we may have a common API among all of them at some point :-)

Comment thread miio/discovery.py Outdated
Comment thread miio/discovery.py Outdated
Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
Comment thread miio/waterheater.py Outdated
@Zuz666

Zuz666 commented Nov 5, 2021

Copy link
Copy Markdown
Contributor Author
  • Add an entry to README.md
  • Move the code to be under miio/integrations/heater/viomiwaterheater/ - there are other heaters so we may have a common API among all of them at some point :-)

@rytilahti Job done! Please perform a code review.

@Zuz666
Zuz666 requested a review from rytilahti November 5, 2021 21:00

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looking good, I added a couple of very minor changes.

Could you also please add at least tests to the container functionality (see #1174 (review))?

Comment thread miio/device.py Outdated
Comment thread miio/integrations/waterheater/viomi/viomiwaterheater.py Outdated
Comment thread miio/integrations/waterheater/viomi/viomiwaterheater.py Outdated
Comment thread miio/integrations/waterheater/viomi/viomiwaterheater.py Outdated
Comment thread miio/integrations/waterheater/viomi/viomiwaterheater.py Outdated
Comment thread miio/integrations/waterheater/viomi/viomiwaterheater.py Outdated
@Zuz666
Zuz666 requested a review from rytilahti November 6, 2021 16:42
@Zuz666

Zuz666 commented Nov 6, 2021

Copy link
Copy Markdown
Contributor Author

Looking good, I added a couple of very minor changes.

Could you also please add at least tests to the container functionality (see #1174 (review))?

Some code for testing done but how can I run this test? Newbie to python. )))

@rytilahti

rytilahti commented Nov 6, 2021

Copy link
Copy Markdown
Owner

Simply execute pytest and it should pick it automatically (as long as the filename and the test functions follow the test_* pattern) :-) btw, did you forget to add the test file to the PR?

You can also run the linting tests locally (tox -e lint or pre-commit run -a) or the whole test suite (simply tox) if you wish.

…terheater.e1)

- Modernize device integration under miio.integrations.viomi.waterheater
- Update ViomiWaterHeaterStatus to use @sensor and @setting decorators
- Add container unit tests based on DummyDevice
- Simplify control methods and error handling
- Register device export in miio.__init__ and README.md
@Zuz666

Zuz666 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Hi @rytilahti,

I have fully rebased this PR on top of the current master and modernized the codebase to align with the current architecture!

Here is a summary of the updates:

  • Rebase & Modernization: The code was moved to miio.integrations.viomi.waterheater following the latest manufacturer/device folder structure.
  • Decorators & API: Transformed ViomiWaterHeaterStatus to inherit from DeviceStatus and use @sensor and @setting decorators. Dropped obsolete patches and cleaned up redundant else blocks in control methods.
  • Unit Tests: Added full unit tests (test_viomiwaterheater.py) utilizing DummyDevice. All tests successfully pass and validate status parsing and operations.
  • Real Device Verification: Executed a live smoke test against a real viomi.waterheater.e1 device, verifying proper parsing and typing of the properties.

Please take a look and let me know if anything else is needed!

@Zuz666

Zuz666 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a fix for the CI linting issues (pre-commit hooks: docstring placement, zip strict parameter, and f-strings).

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.45%. Comparing base (9a00e08) to head (e278fbf).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #834      +/-   ##
==========================================
+ Coverage   84.31%   84.45%   +0.13%     
==========================================
  Files         201      204       +3     
  Lines       20656    20836     +180     
  Branches     1121     1126       +5     
==========================================
+ Hits        17417    17597     +180     
  Misses       3047     3047              
  Partials      192      192              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@Zuz666

Zuz666 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Added unit tests for set_bacteriostatic_mode to achieve 100% patch coverage and resolve the Codecov warning.

@Zuz666

Zuz666 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Also added a computed bacteriostatic_mode_active sensor to ViomiWaterHeaterStatus. Since the device relies purely on targetTemp == 80 for this feature and has no native toggle, this computed property will give downstream integrations (like Home Assistant) a convenient binary sensor to observe the mode's status.

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.

3 participants