Commit Graph

58 Commits (2df13d01187a4fac2f9038facc180eb2c2543712)

Author SHA1 Message Date
Ville Skyttä 5626cc4524
Use http.HTTPStatus in components/r* (#58288) 2021-10-23 20:53:39 +02:00
Chris Browet 1867d24b18
Add state_class support to Rest (#58026) 2021-10-22 13:48:13 -07:00
Marc Mueller 69e413ac1e
Update pylint to 2.10.1 (#54963)
* Update pylint to 2.10.0

* useless-suppression

* Consider-using-tuple

* Apply suggestions from code review

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Use dict.items()

* Add pylint disable

* Use pylint 2.10.1

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-08-21 10:41:23 +02:00
Ville Skyttä 939fde0a50
ConfigType and async_setup/setup type hint improvements (#54739) 2021-08-18 13:22:05 +02:00
Erik Montnemery e558b3463e
Move temperature conversions to sensor base class (6/8) (#54476)
* Move temperature conversions to entity base class (6/8)

* Fix tests
2021-08-12 17:40:55 +02:00
tkdrob 2d5f5bfa9f
Add targets and selectors for services (P-R) (#50628) 2021-05-14 22:07:17 -07:00
Franck Nijhof 055cdc64c0
Add support for IoT class in manifest (#46935) 2021-04-15 10:21:38 +02:00
J. Nick Koston 30382c3dbe
Limit log spam from rest and include reason in platform retry (#48666)
- Each retry was logging the error again
- Now we set the cause of the PlatformNotReady to allow Home Assistant to log as needed
2021-04-04 20:26:18 -07:00
Erik Montnemery 64bc9a8196
Migrate integrations r-s to extend SensorEntity (#48215) 2021-03-22 19:54:14 +01:00
J. Nick Koston fea0e39fa0
Reduce rest setup code (#48062)
- Switch to storing each platform config/rest data in a list
2021-03-18 09:55:38 +01:00
J. Nick Koston dd56cc8010
Fix rest sensor data misalignment with multiple sensors (#48043)
If there were multiple rest data sources, the index needed
to be incremented by type instead of by data source/type
2021-03-17 22:47:42 +01:00
Erik Montnemery 14ff6d4d1f
Update integrations p-s to override extra_state_attributes() (#47759) 2021-03-11 21:23:20 +01:00
Ville Skyttä dc880118a4
Lint suppression cleanups (#47248)
* Unused pylint suppression cleanups

* Remove outdated pylint bug references

* Add flake8-noqa config and note to run it every now and then

* Add codes to noqa's

* Unused noqa cleanups
2021-03-02 09:02:04 +01:00
J. Nick Koston 2f3c2f5f4d
Add support for using a single endpoint for rest data (#46711) 2021-02-19 21:44:15 -08:00
Franck Nijhof a80921ab65
Minor service definition tweaks (#46741) 2021-02-18 17:14:36 +01:00
Aleksander Żarczyński bc3610c8e1
Add patch method to rest switch component (#45663) 2021-01-29 16:03:00 +01:00
J. Nick Koston 661eb0338a
Fix templates for rest notify (#44724) 2021-01-01 19:28:20 +01:00
J. Nick Koston 681f76b99d
Fix rest notify GET without params configured (#44723) 2021-01-01 12:40:08 +01:00
emufan 61c57d4d56
Add another xml content type for JSON conversion in RESTful sensor (#44312)
* Update sensor.py

Some xml-result is passed via "application/xhtml+xml" instead of text/xml or application/xml. And then the xml structure is not parsed to json as expected. I changed it locally, but suggest to add thise here as well.

* Update homeassistant/components/rest/sensor.py

Fine for me as well, as it is working this way as well. But I would not see any disadvantage to convert everything, what is possible - a better scrape sensor this way. ;)

Co-authored-by: J. Nick Koston <nick@koston.org>

Co-authored-by: J. Nick Koston <nick@koston.org>
2020-12-18 14:27:12 -06:00
J. Nick Koston dd0afc3b66
Create httpx helper to wrap a shared httpx.AsyncClient (#43877)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-12-09 17:18:57 +01:00
Moritz Schmitz von Hülst 434d39a5ea
Add initial rest query params (#42198)
* add initial rest query params

* of course I didn't run black

* fix tests

* fix tests

* add test

* reformat

* add binary sensor test

* fix tests

* add one more test and fix switch

* should not have touched that

* if you don't pay attention once
2020-11-11 09:03:55 -10:00
J. Nick Koston 9e0043fb17
Fix rest sensors with resource templates (#42818) 2020-11-04 08:52:47 +01:00
Franck Nijhof 0e98bc5ea2
Skip template result parsing in several places (#42408)
* Skip template result parsing in several places

* Adjust alert integration

* Adjust Alexa integration

* Adjust apns integration

* Adjust arest integration

* Adjust dialogflow integration

* Adjust generic camera integration

* Adjust imap email content  integration

* Adjust InfluxDB integration

* Adjust intent integration

* Adjust logbook integration

* Adjust HP ILO integration

* Adjust manual alarm control panel integration

* Adjust manual mqtt alarm control panel integration

* Adjust minio integration

* Adjust mqtt integration

* Adjust notify integration

* Adjust persistent notification integration

* Adjust rest integration

* Adjust rss feed template integration

* Adjust slack integration

* Adjust Xiaomi integration

* Adjust TCP integration

* Adjust Telegram Bot integration

* Bump CI cache version

* Revert "Bump CI cache version"

This reverts commit 875efe58cf.

* Adjust demo tests
2020-10-26 19:29:10 +01:00
Paulus Schoutsen 8949eb2442
Add httpx as a core dep (#42071) 2020-10-19 10:18:47 +02:00
J. Nick Koston 5580b21260
Decouple RestData from rest.sensor (#41980) 2020-10-17 04:56:45 +02:00
Philip Allgaier dde6305549
Cleanup unused loggers (components N-Z + tests) (#41982) 2020-10-16 21:24:08 -05:00
J. Nick Koston ad6ce5fa83
Convert rest sensors to async using httpx (#41973) 2020-10-16 19:21:13 -05:00
jjlawren f01a0f9151
Allow separate URL for REST switch state (#39557) 2020-09-04 16:58:40 +02:00
J. Nick Koston 661b593db3
Support reloading the rest notify platform (#39527)
* Support reloading the rest notify platform

* update services.yaml

* fix conflict
2020-09-02 18:25:43 -05:00
J. Nick Koston 5018e53b33
Add the ability to reload the rest platforms from yaml (#39257)
* Add the ability to reload rest platforms from yaml

* Revert changes to notify as these will be done in another pass
2020-08-25 19:05:29 -05:00
Franck Nijhof 53545c984b
Log lines do not end with a full stop (#37527) 2020-07-05 23:04:19 +02:00
Franck Nijhof 02adcc532f
Fix rest to use BinarySensorEntity (#37054) 2020-06-24 14:53:17 +02:00
Hedgehog57 fd1edf1bb6
Add resource_template to rest binary_sensor (#30703) 2020-06-23 15:08:55 -07:00
Erik Montnemery 066e921a8b
Rename SwitchDevice to SwitchEntity (#34673) 2020-04-26 18:50:37 +02:00
Erik Montnemery b022e08db9
Rename BinarySensorDevice to BinarySensorEntity (#34462)
* Rename BinarySensorDevice to BinarySensorEntity

* Tweak

* Move deprecation warning to __new__, add test

* Move deprecation warning back to __init__

* Move deprecation warning to __init_subclass
2020-04-23 21:57:07 +02:00
springstan 4c38e6cfa5
Use HTTP_BAD_REQUEST constant (#33797) 2020-04-09 21:43:42 +02:00
springstan fb8f8133a0
Use HTTP_INTERNAL_SERVER_ERROR constant (#33832) 2020-04-08 23:20:03 +02:00
springstan 8d61893c39
Use HTTP_OK constant (#33798)
* Use http ok constant

* Remove incorrect use

* Run isort

* Fix pylint by adding missing imports

* Fix pylint by fixing one import
2020-04-08 11:47:38 -05:00
Paulus Schoutsen f1d3c0d19b
Remove unused manifest fields (#33595) 2020-04-03 12:58:19 -07:00
J. Nick Koston 7f91501a36
Use a requests Session for rest sensors (#32463)
This avoids the ssl setup overhead for each request
2020-03-04 08:32:38 -08:00
J. Nick Koston 924c313c8a
Add application/xml as an XML to JSON auto converted mime type… (#32289)
* Resolves issue #32280
2020-03-01 23:22:01 -08:00
J. Nick Koston c7f128f286
Ensure rest sensors are marked unavailable when http requests… (#32309) 2020-02-28 11:41:41 -08:00
Alok Saboo 2fb66fd866
Add additional logging to rest sensor (#32068) 2020-02-21 21:11:25 +01:00
J. Nick Koston 096e7cceed
Support XML conversion for RESTful sensors (#31809)
* Support XML conversion for RESTful sensors

Many devices continue to use XML for RESTful
APIs.  Interfacing with these APIs requires custom
integrations or command line fork()/exec() overhead
which many of these devices can work with as if
they were JSON using xmltojson via this spec:
https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html

This change implements converting XML output to
JSON via xmltojson so it can work with the existing
rest sensor component.  As the attributes that
usually need to be scraped are deeper in the document
support for passing in a template to find the
JSON attributes that have been added.  JSON APIs that
do not have their attributes at the top level
can also benefit from this change.

* Auto convert xml, change out the template for jsonpath

* Address review items and potentially unexpected normalize behavior with jsonpath

* Revert "Address review items and potentially unexpected normalize behavior with jsonpath"

This reverts commit fe9e179092.

* json_dict[0] turned out to be needed
2020-02-15 21:10:23 -08:00
Franck Nijhof 22760a0bee Correct names in manifests (Q-S) (#30543) 2020-01-07 08:19:44 -05:00
Bas Nijholt 04225ba802 Sort imports according to PEP8 for rest (#29674) 2019-12-09 12:09:49 +01:00
gjbadros 5f1b0fb15c Allow rest sensor list responses (#28835)
* Make rest sensor a little bit more flexible and allow the response to be a list with 0th element being a dictionary

* Black formatter wanted a different formatting

* Added test case for a list response with dict as 0th element

* Fixed lint error - it thinks a + STRING is an avoidance of using % sequences for log messages; I generally prefer explicit + rather than string juxtaposition for combining string literals, but sounds like that's not the standard

* Fixed test case -- I added it to the wrong scenario and need to use the one with json_attrs.
2019-11-26 22:10:58 +01:00
Tim McCormick 6c6a5c50a5 Fix digest auth rest sensors (#28153)
* Fix digest auth rest sensors

* Refactor to use request()

* Fix black complaints

* Don't rename data variable

Don't rename the data variable, appears several other sensors have been coded to rely on it

* Fix tests

test_setup_missing_schema:
Change the exception to check for to PlatformNotReady. With the change away from prepared statements, we no longer get the MissingSchema error during setup - we get it when we attempt to call the endpoint. Since the result is PlatformNotReady, which is what we want, and the error log clearly contains a note that the schema is incorrect I think this is fine.

test_setup_failed_connect & test_setup_timeout:
These aren't checking for minimum config, and they're not invoking the correct method to have the default config filled in. Therefore I've just added the correct minimum config so these can continue to test what they're there to test.

test_update_request_exception:
Testing a request exception with the assert on line 404! Excellent. Anyway, we've moved from using the requests Session object to the requests.request function - so the patch needed to be altered to ensure the RequestException was raised.

* Remove no longer needed import

* Fix binary sensor test in same way
2019-11-25 23:22:11 -08:00
Fredrik Erlandsson 09d8a4204a Add support for resource_template for rest sensor (#27869)
* add support for resource_template

* fix tests

* updated tests and xor(CONF_RESOURCE_TEMPLATE, CONF_RESOURCE)
2019-10-22 22:43:28 -07:00
Franck Nijhof c7da781efc Update documentation link URL for integrations in all manifests (#27114) 2019-10-02 09:25:44 -07:00