Commit Graph

788 Commits (93072d8ac5fa34e57eade45ca227ad9800890da8)

Author SHA1 Message Date
Renat Sibgatulin dd5baa6e48
Add air-Q integration (air quality sensors) (#76999)
* Added initial files for air-Q integration

* Allow FIXME comments in pylint (temporary)

Also reintroduce --ignore-missing-annotations=y

* Set up air-q entry to connect to aioairq's API (initial attempt)

Also add necessary constants

* Implement a class for sensors and its update logic

Very early stage, WIP

* Zeroconf and authentication are working

* Complete the bare-bone minimal working version

Specifically, make AirQSensor update its values.

* Handle invalid authentication gracefully

* Handle ClientConnectionError gracefully

* Add field hint for the login form

The key in the schema, which defines the form in
`ConfigFlow.async_show_form` is looked up in both `airq/strings/json`
and `airq/translations/en.json`. I am still not 100% sure how this
lookup is performed. WIP

* Minor cleanups

* Extend sensor list to all supported by SensorDeviceClass

Also manage warming up sensors

* aioairq is published to PyPI and mentioned in requirements

* Reordered constants and list content alphabetically

As required by style guides. Also turned SENSOR_TYPES to a list

* Updated file docstrings for a dev unfamiliar w/homeassistant like myself

* Adding a bit of logging for the integration setup process

* Expose scan interval & smoothing flag

Also streamline test_authentication in config_flow.

* Fix a type annotation mistake

* Use as many constants from homeassistant.const as possible

My only concern is using CONST_IP_ADDRESS = "ip_address" for smth which
stands for both IP address and mDNS...

* Temporarily rollback ConfigFlow.async_step_configure and use defaults

TODO: implement OptionFlowHandler instead

* Define custom Coordinator, w subset of airq config

The latter is then accessed from entity / sensor constructors to define
correct DeviceInfo

* Provide translations to de & fr + minor changes to en

* Provide translations to ru + a minor en changes

* Make translation a little more helpful and polite

* Fix devicename and entry title

* Remove stale commented out code

* Test config_flow

At this point two helper functions which interact with the external
library are not tested

* Clean up unrelated and meant as temporary changes

* Clean up unnecessary comments meant for internal use

* Move fetching config to a dedicated async coordinator method

As opposed to it being a potentially poorly justified step in
async_setup_entry

* Remove zeroconf support since it is not yet ready

* Remove translations other than en

* Remove unnecessary comments, manifest.json entries, and constants

* Improve exception handling

- `_LOGGER` uses `debug` and not `error` levels.
- Drop `ClientConnect` and catch `aiohttop.ClientConnectError` directly
- Drop `Exception` as it is not expected from `aioairq` (remove the
  corresponding test too)

* Drop strings for obsolete errors and steps

Specifically, `unknown` error isn't caught any more. `configure` step
has also been removed.

* Refactor en.json to be consistent with strings.json

* Move target_route from a coordinator argument to a constant

At this point a user cannot configure the target_route route, thus it
does not make sense to expose it half-heartedly in
`AirQCoordinator.__init__`, since it cannot be accessed.

* Fix an async call in `AirQCoordinator.async_setup_entry`

* Refactor underlying aioairq API

- Use `homeassistant.helpers.aiohttp.async_get_clientsession` and pass a
  single persistent session to `aioariq.AirQ.__init__`
- `aioairq.AirQ.fetch_device_info` now returns a `DeviceInfo` object heavily
  inspired and almost compatible with `homeassistant.helpers.entity.DeviceInfo`.
  Make heavier use of this object and define a single `DeviceInfo` in the
  `AirQCoordinator` (instead of recreating the same object for each sensor
  of the device in `sensor.AirQSensor`)
- Drop two helper functions in `config_flow.py` and operate on `aioariq.AirQ`
  methods directly

* Fix the version of aioairq

* Add 15 more sensors + icons

* Remove cnt* & TypPS, change units of health & performance

* Add 12 more sensors

* Add a missing icon

* Gracefully handle device not being available on setup

If the device and the host are not on the same WiFi,
ServerTimeoutError is raised, which is caught by
ClientConnectionError.
If the device is powered off, ClientConnectionError is expected.
In both cases, ConfigEntryNotReady is raised, as prescribed by the docs.
Newer version of aioairq times-out far quicker than the default 5 mins.

* Rename two sensors

* Validate provided IP address / mDNS

aioairq now raises InvalidInput if provided IP / mDNS does not seem
valid. Handle this exception correctly

* Apply suggestions from code review

Clean up the comments and rename the logger

Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Artem Draft <Drafteed@users.noreply.github.com>

* Only fetch device info during the first refresh

- Fetched info is stored in AirQCoordinator.device_info.
- In `AirQSensor.native_value` only multiply by the factor if
  the sensor reading is not None
- Fix the tests for ConfigFlow for aioairq==0.2.3. Specifically
  make the dummy data pass the new validation step upstream
  + add a test which fails it

* Drop custom device classes for now

* Apply suggestions from code review

Co-authored-by: Artem Draft <Drafteed@users.noreply.github.com>

* Only fetch device info during ConfigFlow.async_step_user

Store the result obtained by `airq.fetch_device_info` it in
`config_entry.data`. Pass the entire config entry to `AirQCoordinator`
and build the entire `homeassistant.helpers.entity.DeviceInfo` in the
`AirQCoordinator.__init__`. This makes
`AirQCoordinator._async_fetch_device_info` and overloaded
`AirQCoordinator._async_config_entry_first_refresh` obsolete.

Bump aioairq version.

Turn update_interval from `AirQCoordinator.__init__` argument into a
contestant.

* Custom entity description exposing a hook to modify sensor value

Use a `AirQEntityDescription` with a callable `value_fn` which allows to
change the sensor value retrieved from the device. Note that the
callable does not handle data retrieval itself (even from
`coordinator.data`). Instead it is purely a hook to transform obtained
value.

* Avoid duplicated use of unique_id

Device info is fetched  during the `ConfigFlow.async_user_step`.
`unique_id` is taken from the device info and is **not** stored
in `config_entry.data`. Subsequently `config_entry.unique_id` is
used instead.

* Drop unnecessary try-except

Co-authored-by: Artem Draft <Drafteed@users.noreply.github.com>

* Clarify the use of value_transform_fn

* Refactor the use of lambdas in AirQEntityDescription

Now it is the job of the callable under `value` to get the sensor
reading from the coordinator's data. Factoring this functionality into a
callback decouples  the key of the description from the key of dict,
returned by the API, so `AirQEntityDescription` no longer requires its key
to be set to smth clearly internal (e.g. `nh3_MR100`).

* Use a callback to update native_value

Since all `native_value`s are updated synchronously, it can as well be
done in a callback for better state consistency (right?)

* Revert the description keys to match data keys

Must match given the current way of identifying available sensors. On a
broader scale, they must match to be able to relate the descriptions to
sensors, unless a separate lookup table is maintained.

* Reduce number of loops when adding sensors

Filtering warming up sensors and non-sensor keys can be combined with
adding entities.

* Remove obsolete imports

* Update integrations.json

* Add integration_type

Integration supports multiple devices => hub

Co-authored-by: dl2080 <daniel.lehmann@runbox.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Artem Draft <Drafteed@users.noreply.github.com>
Co-authored-by: Daniel Lehmann <43613560+dl2080@users.noreply.github.com>
Co-authored-by: Martin Selbmann <job@martin-selbmann.de>
2022-11-03 23:13:57 +01:00
Malte Franken ee4d28000d
Add integration_type to gdacs (#81451) 2022-11-03 09:32:40 +01:00
Rami Mosleh fc3843f5e2
Add config flow to `pushbullet` (#74240)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-11-02 16:11:44 +01:00
Aidan Timson d6689937a3
Add integration type to OVO Energy (#81187) 2022-10-31 20:42:02 +01:00
Aidan Timson 8044b9587a
Add integration type to System Bridge (#81186) 2022-10-31 20:41:12 +01:00
aschmitz a766b41b13
Add basic Aranet integration (#80865) 2022-10-30 22:50:46 -05:00
G Johansson 7bd89621ce
Change IoT Class for Min/Max to calculated (#81199) 2022-10-29 14:21:28 -04:00
epenet 7feb463a4c
Add integration_type to samsungtv (#81101) 2022-10-27 19:18:09 +03:00
Steven Looman d50795af2b
Move upnp derived sensors to library, be more robust about failing getting some data (#79955) 2022-10-26 14:34:44 -05:00
Daniel Gangl b2b3c47917
Add config flow to zamg (#66469) 2022-10-26 18:35:12 +02:00
Marc Mueller b148cdd64a
Add integration type to fritzbox_callmointor integration (#81032) 2022-10-26 18:19:54 +02:00
Raman Gupta 1b3c383558
Add integration_type to vizio, tomorrowio, zwave_js (#80975) 2022-10-25 23:31:44 +02:00
Aaron Bach 2af58ad609
Set integration type on codeowned integrations @bachya (#80974) 2022-10-25 22:23:54 +02:00
Franck Nijhof 98591cd4b6
Remove hardware and fix raspberry pi brands in integrations.json (#80970) 2022-10-25 21:05:04 +02:00
Erik Montnemery 3aa64aaaf1
Mark some integrations as system integrations (#80948) 2022-10-25 15:30:46 +02:00
Bram Kragten 36bb0bbc1a
Fix `integrations.json` creation, make `iot_standards` a list (#80945) 2022-10-25 13:43:40 +02:00
hackerESQ f977b264a1
Add tplink dhcp entry for EP25 model (#80650)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-10-25 13:22:09 +02:00
Franck Nijhof 52f109f6ab
Add IKEA SYMFONISK as virtual integration (#80833) 2022-10-25 12:09:22 +02:00
J. Nick Koston 559e281431
Add oralb integration (#80918)
* mapping

* update

* working

* tests

* fixes

* temp add binary sensor platform to make sure it works

* fixes

* 100% cover

* adjust

* disable chatty sensors by default

* remove binary sensor_platform for next PR

* time is much nicer than counter
2022-10-24 23:11:40 -05:00
Simon Hansen b56d332c26
Add integration_type to launchlibrary (#80907) 2022-10-24 23:23:14 +02:00
Simon Hansen 2ddf1f9416
Add integration_type to iss (#80909) 2022-10-24 23:19:59 +02:00
Kevin Addeman fdcce0446c
Add Lutron Caseta zeroconf discovery for RA3/HWQSX (#80852) 2022-10-23 18:17:36 -05:00
Franck Nijhof d4a5393f7b
Set integration type on codeowned integrations @frenck (#80830) 2022-10-23 20:43:13 +02:00
Chris Talkington 9734086d9b
Add integration_type to jellyfin (#80832) 2022-10-23 13:42:25 -05:00
Chris Talkington 18f51db15d
Add integration_type to ipp and roku (#80831) 2022-10-23 13:31:24 -05:00
Steven Hosking c4831333fa
Extend roomba mac range in manifest (#80714)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-10-22 10:44:25 -05:00
Guido Schmitz 85dda68524
Add integration_type to devolo integrations (#80695) 2022-10-22 15:55:23 +02:00
Maciej Bieniek b6b36861d9
Add `integration_type` field for a few integrations (#80767) 2022-10-22 14:38:08 +02:00
Paulus Schoutsen e38d93ee93
Remove unused keys from ultraloq (#80762) 2022-10-21 20:56:20 -04:00
Paulus Schoutsen 43d43689f7
Add ultraloq virtual integration (#80755) 2022-10-21 20:29:01 -04:00
Paulus Schoutsen 76dbd017a7
Conditionally include config flow and iot_class when relevant (#80756) 2022-10-21 20:27:59 -04:00
Guido Schmitz 78f71c46da
Add iot_standards to devolo brand (#80332) 2022-10-21 11:25:35 +02:00
Franck Nijhof bb287dd0ed
Integrations v2.1: Virtual integrations (#80613) 2022-10-20 23:09:06 -04:00
Robert Svensson 60a208a860
Add integration_type to Axis, deCONZ and UniFi manifest (#80630) 2022-10-19 21:56:19 +02:00
Franck Nijhof c4bbc439a5
Integrations v2.1: Differentiating hubs, devices and services (#80524)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-10-19 12:41:43 +02:00
Franck Nijhof 40bfc61ebd
Revert "Add Mazda brand" (#80314) 2022-10-14 15:48:10 +02:00
Lén 0f9703cd99
Add Heiwa as supported brand (#80242) 2022-10-14 10:19:32 +02:00
Austin Brunkhorst 7d097d18b0
Add support for Snooz BLE devices (#78790)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-10-10 13:14:27 -10:00
Franck Nijhof 907af7ffe4
Remove system marker from Supervisor integration (#79997) 2022-10-10 11:05:28 +02:00
starkillerOG 7bc2d97aca
Add Roborock as supported brand of xiaomi miio (#79312)
* Add Roborock as supported brand

* Update supported_brands.py
2022-10-08 12:55:56 -06:00
spycle e2b7e79ccb
Fix keymitt_ble discovery (#79809)
* Fix keymitt_ble discovery

* Update tests

* Up version

* Up version keymitt_ble

* Up version keymitt_ble
2022-10-08 08:19:40 +02:00
Brandon Rothweiler 2452e70e29
Add Mazda brand (#79683) 2022-10-07 17:49:47 -06:00
Glenn Waters d3fee8aad9
Add supported brands to UPB integration (#79619) 2022-10-06 20:33:37 +02:00
Jafar Atili 92c9ddf3e3
Add supported brands for switchbee (#79595) 2022-10-05 09:25:46 +02:00
Tobias Sauerwein 905950f341
Netatmo add supported brands (#79563) 2022-10-05 08:58:24 +02:00
Paulus Schoutsen abc80d8245
Add a couple more brands (#79600) 2022-10-04 11:45:40 -04:00
Franck Nijhof 2b27cfdabb
Set system & entity integration types (#79593) 2022-10-04 10:36:42 -04:00
Franck Nijhof 74a8472eed
Collect all brands (#79579) 2022-10-04 09:24:55 -04:00
J. Nick Koston 52cdae254c
Bump govee-ble to 0.19.1 to handle another H5181 (#79340)
fixes #79188
2022-09-30 10:33:14 +02:00
Zack Barett 0001270bad
Add Third Reality to Zigbee Iot standards (#79341) 2022-09-29 23:13:09 -04:00