Commit Graph

55 Commits (b07e9df308a2fec26d76ee0ae046c5699d0546d1)

Author SHA1 Message Date
Jan Bouwhuis c7eab49c70
Raise ServiceValidationError on invalid select option (#106350)
* Raise ServiceValidationError on invalid select option

* Fix tests

* Correct place holders

* More test fixes
2023-12-27 09:45:55 +01:00
Joost Lekkerkerker a82410d5e9
Deduplicate constants E-Z (#105657) 2023-12-13 17:05:37 +01:00
Joost Lekkerkerker ac53b78a0c
Deduplicate constants A-D (#105638) 2023-12-13 14:21:44 +01:00
J. Nick Koston 0eca433004
Update zeroconf discovery to use IPAddress objects to avoid conversions (#100567) 2023-09-19 18:58:46 +02:00
Jan Bouwhuis 8b6ed9c6b9
Fix test with time issue for xiaomi_miio button (#95438) 2023-06-28 13:19:24 +02:00
zry98 bafb81337b
Add buttons for resetting vacuum consumable status in xiaomi_miio (#91483)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Eugenio Panadero <eugenio.panadero@gmail.com>
2023-06-27 21:58:29 +02:00
epenet 5b80b1f55a
Add type hints to integration tests (part 25) (#88308) 2023-02-17 16:52:28 +01:00
Franck Nijhof d3ed8de232
Update Ruff to v0.0.247 (#88210)
* Update Ruff to v0.0.247

* Fix new found violations
2023-02-15 16:46:03 -05:00
Franck Nijhof ed79265843
Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet 278050a73f
Add type hints to integration tests (t-z) (#87707) 2023-02-08 19:10:53 +01:00
starkillerOG a2080492de
Remove Xiaomi Miio YAML import (#78995)
* Deprecate YAML import

* Add logging for unexpected errors

* remove unused import

* fix tests

* unused import

* fix tests

* fix snake_case

* Do not add to standard key string
2022-10-21 18:07:49 +02:00
epenet 7bc2712142
Adjust root-import in tests (#78761)
* Adjust root-import in tests

* Adjust diagnostics

* Adjust button

* Adjust select

* Adjust device_tracker

* Adjust camera

* Adjust humidifier

* Adjust media_source

* Adjust update

* Adjust siren

* Adjust number

* Adjust alarm_control_panel

* Adjust notify

* Adjust sensor

* Adjust switch

* Revert anthemav

* Don't adjust demo humidifier
2022-09-19 15:22:23 +02:00
epenet e9f55f4e54
Apply hass-relative-import to tests (s-z) (#78733) 2022-09-19 09:51:31 +02:00
Igor Pakhomov 65f86ce44f
Add additional select for dmaker.airfresh.t2017 to xiaomi_miio (#67058) 2022-08-16 17:30:56 +02:00
Franck Nijhof 7cd68381f1
Search/replace RESULT_TYPE_* by FlowResultType enum (#74642) 2022-07-07 19:57:36 +03:00
epenet 014aadb299
Use new CONF_MODEL core constant (2/3) (#68831)
* Use CONF_MODEL in xiaomi_miio

* Use CONF_MODEL in xiaomi

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-29 11:12:43 +02:00
Joshua Roys 9134e5c844
Get discovered zeroconf IPv6 addresses (#65462) 2022-02-11 16:46:17 -06:00
Teemu R 908b7ca9c2
Bump xiaomi_miio dependency (#60650) 2021-12-01 08:08:59 +01:00
epenet 9f74ad06d6
Update ZeroconfServiceInfo in tests (t-z) (#60221)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-23 11:28:50 -06:00
epenet 2cd241ff0a
Use ZeroconfServiceInfo in xiaomi_miio (#60132)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-22 08:18:22 -06:00
Franck Nijhof 01efe1eba2
Add datetime object as valid StateType (#52671)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-11-18 14:11:44 +01:00
Teemu R ea657e6656
Accept all roborock vacuum models for xiaomi_miio (#59018) 2021-11-04 14:14:31 +01:00
starkillerOG e34aed743c
Xiaomi Miio appropriatly raise ConfigEntryAuthFailed/ConfigEntryNotReady (#54696)
* Add reties to cloud login

* push to version 0.4 of micloud

* distinguish between authentication error and socket errors

* raise from error

* Update homeassistant/components/xiaomi_miio/gateway.py

Co-authored-by: Franck Nijhof <git@frenck.dev>

* move ConfigEntryNotReady to connect function

* remove unused import

* also add ConfigEntryNotReady for device

* catch exceptions in config flow

* fixes

* bring tests back to 100%

* add missing catch exception

* add test

* fix black

* Update homeassistant/components/xiaomi_miio/device.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update homeassistant/components/xiaomi_miio/gateway.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update tests/components/xiaomi_miio/test_config_flow.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* fix tests

* define specific exceptions

* fix styling

* fix tests

* use proper DeviceException

* Revert "use proper DeviceException"

This reverts commit 0bd16135387cd6d9e563cd62ac147d0a25c577f3.

* use appropriate side-effect

* remove unused returns

* Update homeassistant/components/xiaomi_miio/const.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* remove unused returns

Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Teemu R. <tpr@iki.fi>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-15 01:25:44 +02:00
Kevin Hellemun dc5e4392ae
Refactor Xiaomi vacuum to sensors (#54990)
* Refactor Xiaomi vacuum with sensors.

This is the first step into refactoring xiaomi vacuum attributes into sensors.
What is missing are some switches and binary sensors etc.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Use generic sensor for Xiaomi vacuum sensors.

By using HA coordinator, the generic Xiaomi sensor class can be used with these
coordinators to get the status sensors from vacuum. This also means now that
sensors are available as soon as HA starts, which is a nice plus.

Now the only reason to create a subclass of the generic sensors is when custom
value parsing needs to be done.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Working vacuum sensors via 1 coordinator.

Vacuum needs a custom coordinator to ensure that it fetches all the needed data
and puts it in a dict. From this dict the sensors will then get their data
accordingly.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Remove vacuum setup method in sensor

Sensor is generic enough that vacuum does not require its own setup method.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Don't auto register generic sensors.

Let the user decide which sensor is useful for them and enable them.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Remove converted attributes from xiaomi vacuum.

The attributes that have been converted so far should be removed from the vacuum
attributes list.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Fetch data from vacuum sequentially.

It seems some vacuums do not like parallel requests. The requests that came
before are ignored.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Refactor vacuum sensors to its own container.

By moving vacuum sensors to its own container, there is no more key collisions.
This in turns means that there is need for the split hack to ensure key names
are correct.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* fixup! fix bad rebase.

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Fix sensor naming and default registration.

Use proper names for sensors, no need to include from which device status it
came.

Registration of the sensor by default has been parameterised. If the param is
not set, the sensor is not registered.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Make vacuum platform also use coordinator for its data.

By using the coordinator for data in vacuum platfrom, removes the cases where
request gets ignored during the case where the requests are done concurrently by
separate platforms.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Add binary sensor for vacuum

Add binary sensor for waterbox, mop, and water shortage.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Added proper icons to sensors.

https://github.com/home-assistant/core/issues/51361

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Refactor sensors to use dataclass.

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Make vacuum use coordinator for its data.

This commit also insures that the binary sensors are only registered for devices
that include a mop.

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Minor refactoring

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Update data from coordinator after running command.

This is is to have a faster status change when executing a command like changing
fan speeds. If a manual refresh is not triggered. Worst case scenario it will
take 10s for the new fan speed to be reported in HA.

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Refresh within coroutine is ok.

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Move logging to _handle_coordinator_update

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Use internal state attribute.

Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>

* Fix vacuum typing

* Fix tests constants

* Fix vacuum inconsistent return values

* Fix vacuum state update

* Fix vacuum tests

* Remove impossible cases

* Parametrize custom services test

* Move goto test

* Move clean segment test

* Move clean single segment test

* Test service pause

* Include vacuum in coverage

* Delint

* Fix vacuum sensor dict collision.

This also prevents collision for unique id. As the key is used to construct
unique ids.

* Use f strings as dict keys

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-07 18:30:17 +02:00
Paulus Schoutsen a4d9019ffc
Refactor persistent notification to no longer route all data via a service (#57157)
* Convert persistent notification tests to async

* Create/dismiss persistent notifications in exposed functions, not service calls

* Fix notify persistent_notification

* Remove setting up persistent_notification

* Drop more setups

* Empty methods

* Undeprecate sync methods because too big task

* Fix setup clearing notifications

* Fix a bunch of tests

* Fix more tests

* Uno mas

* Test persistent notification events

* Clean up stale comment

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-07 12:58:00 +02:00
starkillerOG 3a2d50fe23
Add Xiaomi Miio EU gateway support (#47955)
* Add EU gateway support

* add options flow translations

* fix options flow

* fix missing import

* try to fix async_add_executor_job

* try to fix async_add_executor_job

* fix unload

* check for login succes

* fix not reloading

* use cloud option

* fix styling

* Return after if

Co-authored-by: Nathan Tilley <nathan@tilley.xyz>

* cleanup

* add options flow tests

* fix new tests

* fix typo in docstring

* add missing blank line

* Use async_on_unload

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Use async_on_unload

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Use async_setup_platforms

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Use async_unload_platforms

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/xiaomi_miio/__init__.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/xiaomi_miio/const.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* default use_cloud False

* add options flow checks

* fix styling

* fix issort

* add MiCloud check tests

* fix indent

* fix styling

* fix tests

* fix tests

* fix black

* re-write config flow

* add explicit return type

* update strings.json

* black formatting

* fix config flow

Tested the config flow and it is now fully working

* fix styling

* Fix current tests

* Add missing tests

* fix styling

* add re-auth flow

* fix styling

* fix reauth flow

* Add reauth flow test

* use ConfigEntryAuthFailed

* also trigger reauth @ login error

* fix styling

* remove unused import

* fix spelling

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Fix spelling

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* fix spelling

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* remove unessesary .keys()

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* combine async_add_executor_job calls

* remove async_step_model

* fix wrong indent

* fix gatway.py

* fix tests

Co-authored-by: Nathan Tilley <nathan@tilley.xyz>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-06-15 00:05:40 +02:00
Ville Skyttä 7d03b02192
Spelling fixes (#51642) 2021-06-11 13:35:03 +02:00
J. Nick Koston bf2d40adfe
Migrate from pytz to python-dateutil (#49643)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-07 22:46:26 -07:00
Ruslan Sayfutdinov 82c94826fb
Enable strict typing for zeroconf (#48450)
* Enable strict typing for zeroconf

* Fix lutron_caseta

* Fix pylint warning

* Fix tests

* Fix xiaomi_aqara test

* Add __init__.py in homeassistant.generated module

* Restore add_job with type: ignore
2021-03-30 06:48:04 -10:00
starkillerOG 1c9a9be197
Fix Xiaomi Miio discovery (#47134) 2021-02-28 12:25:40 -08:00
starkillerOG 338c07a56b
Add Xiaomi Miio vacuum config flow (#46669) 2021-02-22 13:01:02 +01:00
starkillerOG 2f9fda73f4
Add config flow to Xiaomi Miio switch (#46179) 2021-02-15 20:11:27 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Teemu R bdb71c9159
Only log xiaomi_miio update exceptions once (#41226)
* xiaomi_miio: only log update exceptions once

Replaces #37695

* add som more missed exception logger cases + do not change the control flow as pointed out by @cgtobi

* Use patch&MagickMock from tests.async_mock

* Fix linting for alarm_control_panel

* update the test to verify that the warning on update is only logged when the device was previously available
2020-10-25 01:53:36 +02:00
Brig Lamoreaux 58a432685c
Use common srings in xiaomi-miio (#41864) 2020-10-15 08:09:20 +02:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
starkillerOG ffcdd85117
Xiaomi Gateway subdevice support & AqaraHT + SensorHT devices (#36539)
* Gateway subdevice support & AqaraHT + SensorHT devices

* Gateway subdevice support & AqaraHT + SensorHT devices

* Add starkillerOG to codeowners

as proposed by @rytilahti in this issue: https://github.com/home-assistant/core/issues/36516

* add starkillerOG to xiaomi_miio

* fix config flow tests

* Update CODEOWNERS

* Update manifest.json

* prosess revieuw comments

* fix missing import

* use proper pressure unit hPa

* subdevice --> sub_device

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* subdevice --> sub_device

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* use key acces instead of get

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* subdevice --> sub_device

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* subdevice --> sub_device

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* subdevice --> sub_device

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* subdevice --> sub_device

* use dataclass instead of namedtuple

* update to newest python-miio functions (not yet released)

* Move device info to entitie

* remove unused variable

* improve default names

* SensorHT does not support pressure

* bump python-miio to 0.5.2

* bump python-miio to 0.5.2

* bump python-miio to 0.5.2

* Fix missing brackets

Co-authored-by: Teemu R. <tpr@iki.fi>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Teemu R. <tpr@iki.fi>
2020-07-04 14:56:16 +02:00
Jonas Thuresson 247df5874b
Xiaomii miio vaccum clean segment service (#36801) 2020-06-22 16:37:05 -07:00
MarBra 44708ed8bb
Add timers to xiaomi_miio vacuum (#35417)
* Add timers to xiaomi_miio vacuum

* Add timezone

* Add cron and next_schedule

* Use next_schedule from backend library

* Use as_utc from utils
2020-06-12 06:39:19 +02:00
Jonas Thuresson f522c6c8c7
Add Xiaomi miio vaccum goto service (#35737)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-06-08 14:57:47 +02:00
starkillerOG 256370afa8
Xiaomi Miio zeroconf discovery (#35352) 2020-05-14 15:59:40 +02:00
Paulus Schoutsen 2af984917e
Use asynctest-mock in most places (#35109)
* Use asynctest-mock in most places

* Fix broken patch in pilight
2020-05-03 11:27:19 -07:00
Paulus Schoutsen ec47216388
Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00
starkillerOG e46f1b69ba
Add Xiaomi miio Alarm Control Panel (#32091)
Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>
2020-04-29 01:44:31 +02:00
Teemu R e64104300f
Use backend-provided fan speed presets for Xiaomi vacuums, bum… (#32850)
* Use backend-provided fan speed presets for Xiaomi vacuums

This needs input from Xiaomi vacuum owners to verify that it does not break anything.
I have personally tested this on rockrobo v1 (old mapping).

Related issues/PRs:
home-assistant/core#32821
home-assistant/core#31268
home-assistant/core#27268

This is a WIP as it requires a new upstream release.
The PR is https://github.com/rytilahti/python-miio/pull/643

* Bump version requirement for 0.5.0

* Bump requirements_test_all.txt, too

* Fix linting; missing setup.cfg on local checkout caused wrong settings for black..

* Add tests for both fan speed types

* Remove useless else..

* bump python-miio to 0.5.0.1 due to broken 0.5.0 packaging
2020-04-02 16:55:44 -07:00
tiagofreire-pt 7052cdded1 Change nomenclature for Roborock fan speeds (#30614)
* Change nomenclature for Roborock fan speeds 

* Update test_vacuum.py

* Update test_vacuum.py
2020-01-09 23:49:13 +01:00
Ville Skyttä fa4fa30461 Various string cleanups (#30435)
* Remove some unnecessary string concatenations

* Replace some simple str.formats with f-strings

* Replace some string concatenations with f-strings
2020-01-03 14:47:06 +01:00
Franck Nijhof 194cb8dbf5 Migrate xiaomi_miio tests from coroutine to async/await (#30329) 2019-12-31 16:49:00 -06:00
Franck Nijhof f5d4878992 Fix isort on a small set of misc files (#29803) 2019-12-10 09:25:42 +01:00
Raman Gupta 040fd9c258 Update service domains for xiaomi_miio from base domains to xiaomi_miio domain (#29134)
* move service constants to const.py, move all custom xiaomi_miio services to xiaomi_miio domain

* update service names

* try to fix black error

* try black formatting again

* final black formatting attempt

* update service names to reflect platform

* fix typo
2019-12-02 11:49:39 -08:00