Commit Graph
56 Commits
Author SHA1 Message Date
Marc MuellerandGitHub 6c5f7eabff Fix RuntimeWarning in rest tests (#146452) 2025-06-10 15:26:07 +02:00
J. Nick KostonandGitHub 7573a74cb0 Migrate rest to use aiohttp (#146306) 2025-06-07 13:44:25 -05:00
ff2c901930 Update trigger based template entity resolution order (#140660)
* Update trigger based template entity resolution order

* add test

* fix most comments

* Move resolution to base class

* add comment

* remove uncessary if statement

* add more tests

* update availability tests

* update logic stage 1

* phase 2 changes

* fix trigger template entity tests

* fix trigger template entities

* command line tests

* sql tests

* scrape test

* update doc string

* add rest tests

* update sql sensor _update signature

* fix scrape test constructor

* move state check to trigger_entity

* fix comments

* Update homeassistant/components/template/trigger_entity.py

Co-authored-by: Erik Montnemery <[email protected]>

* Update homeassistant/helpers/trigger_template_entity.py

Co-authored-by: Erik Montnemery <[email protected]>

* Update homeassistant/helpers/trigger_template_entity.py

Co-authored-by: Erik Montnemery <[email protected]>

* update command_line and rest

* update scrape

* update sql

* add case to command_line sensor

---------

Co-authored-by: Erik Montnemery <[email protected]>
2025-04-25 13:17:25 +02:00
J. Nick KostonandGitHub a150e39922 Bump httpx to 0.28.1, httpcore to 1.0.7 along with required deps (#133840) 2025-01-22 12:50:00 +01:00
2cc38b426a Add XML support to RESTful binary sensor (#110062)
* Add XML support to RESTful binary sensor

* Add test for binary sensor with XML input data

* Address mypy validation results by handling None returns

* Use proper incorrect XML instead of blank

* Change failure condition to match the behavior of the library method

* Change error handling for bad XML to expect ExpatError

* Parametrize bad XML test to catch both empty and invalid XML

* Move exception handling out of the shared method

---------

Co-authored-by: Erik Montnemery <[email protected]>
2024-05-30 16:29:50 +02:00
epenetandGitHub 8d8696075b Use registry fixtures in tests (r) (#118293) 2024-05-28 14:23:31 +02:00
00ec7f11f0 Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <[email protected]>
2024-03-19 09:01:07 +01:00
Marc MuellerandGitHub 7d6251ca08 Add empty line after module docstring [tests q-s] (#112711) 2024-03-08 14:47:22 +01:00
Marc MuellerandGitHub 438d3b01b9 Use builtin TimeoutError [o-s] (#109682) 2024-02-05 12:14:37 +01:00
G JohanssonandGitHub aacb8aecfc Refactor Rest Sensor with ManualTriggerEntity (#97396)
* ManualTriggerEntity for rest sensor

* add availability test

* review comments

* last fixes
2023-08-10 21:46:56 +02:00
epenetandGitHub 580b09d0f2 Refactor XML parsing in rest (#94268)
* Refactor XML parsing in rest

* Adjust caplog check

* Adjust

* Rename

* Simplify
2023-06-15 09:15:25 +02:00
MichaelandGitHub 323d16cc21 Add ssl_cipher_list option to rest (#91078) 2023-04-15 11:22:41 -10:00
MichaelandGitHub 0916701a0b Catch ssl errors in rest (#91074)
* catch ssl.SSLError

* add test

* fail setup on ssl error

* adjust tests
2023-04-12 06:51:41 +02:00
epenetandGitHub f24634e198 Use domain constants in rest tests (#90765) 2023-04-04 14:33:41 +02:00
epenetandGitHub 02e2e4d039 Add rest encoding test (#90404)
* Add rest encoding test

* docstring
2023-03-28 16:29:24 +02:00
Erik MontnemeryandGitHub cf7e500a8e Support translating entity names (#88242) 2023-03-12 15:55:04 +01:00
epenetandGitHub c1589d3c89 Adjust invalid test values in rest (#86009) 2023-01-16 13:37:38 +01:00
MichaelandGitHub 72d3fa6d89 Replace the usage of unit constants by enumerations in Tests [o-r] (#85936) 2023-01-15 14:50:24 +01:00
Franck NijhofandGitHub 2e92fefc0a Fix uom/device class mismatches in tests (#84372) 2022-12-21 22:47:59 +01:00
Franck NijhofandGitHub 762eb57636 Validate state class and unit of measurement for non-numeric sensors (#83344)
* Validate state class and unit of measurement for non-numeric sensors

* Remove duration

* Fix rest tests
2022-12-06 00:07:02 +01:00
epenetandGitHub a0ed91e30c Add type hints to rest tests (#81304) 2022-10-31 15:30:29 +01:00
Erik MontnemeryandGitHub 5987266e56 Refactor template entity to allow reuse (#72753)
* Refactor template entity to allow reuse

* Fix schema and default name

* Add tests

* Update requirements

* Improve test

* Tweak TemplateSensor initializer

* Drop attributes and availability from TemplateEntity

* Use rest sensor for proof of concept

* Revert changes in SNMP sensor

* Don't set _attr_should_poll in mixin class

* Update requirements
2022-06-08 15:55:49 +02:00
1bd904b5b5 Use enums for rest tests (#62197)
Co-authored-by: Franck Nijhof <[email protected]>
2021-12-19 18:01:33 +01:00
Erik MontnemeryandGitHub aa36dde148 Correct rest sensor configured to generate timestamps (#61429) 2021-12-10 09:59:27 -08:00
Paulus SchoutsenandGitHub 31153ac155 Move fixtures part 1 (#58902) 2021-11-01 20:47:05 -07:00
Chris BrowetandGitHub b1b782419b Add REST sensor/binary_sensor/switch templated headers & params (#54426) 2021-10-29 16:36:47 -05:00
Ville SkyttäandGitHub 5626cc4524 Use http.HTTPStatus in components/r* (#58288) 2021-10-23 20:53:39 +02:00
Chris BrowetandGitHub 1867d24b18 Add state_class support to Rest (#58026) 2021-10-22 13:48:13 -07:00
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 <[email protected]>
2021-10-07 12:58:00 +02:00
J. Nick KostonandGitHub 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
J. Nick KostonandGitHub 2f3c2f5f4d Add support for using a single endpoint for rest data (#46711) 2021-02-19 21:44:15 -08:00
Franck NijhofandGitHub 65cf2fcb6f Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
dd0afc3b66 Create httpx helper to wrap a shared httpx.AsyncClient (#43877)
Co-authored-by: Paulus Schoutsen <[email protected]>
2020-12-09 17:18:57 +01:00
Jonas LundbergandGitHub a5279cc279 Upgrade respx to 0.16.2 (#43892)
* Bump respx to 0.16.2

* Align sensor tests to use new respx mock api
2020-12-04 04:27:25 +01:00
Moritz Schmitz von HülstandGitHub 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 KostonandGitHub 9e0043fb17 Fix rest sensors with resource templates (#42818) 2020-11-04 08:52:47 +01:00
J. Nick KostonandGitHub ad6ce5fa83 Convert rest sensors to async using httpx (#41973) 2020-10-16 19:21:13 -05:00
springstanandGitHub 6a7caad8dc Use content type json constant (#40312) 2020-09-23 20:21:55 +02:00
springstanandGitHub 0c077685b6 Use content type text plain constant (#40313) 2020-09-20 13:19:10 +02:00
Franck NijhofandGitHub 1c2ebdf307 Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
J. Nick KostonandGitHub 79f4b6eb6b Cleanup the rest reload test to use the pytest requests_mock fixture (#39282) 2020-08-26 17:53:11 +02:00
J. Nick KostonandGitHub 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
Paulus SchoutsenandGitHub c33edbe5bb Use TestCase.addCleanup (#36560) 2020-06-08 12:26:40 -07:00
276f3afb00 Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <[email protected]>
2020-05-31 22:18:30 -07:00
Paulus SchoutsenandGitHub 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
J. Nick KostonandGitHub 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 KostonandGitHub 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 KostonandGitHub c7f128f286 Ensure rest sensors are marked unavailable when http requests… (#32309) 2020-02-28 11:41:41 -08:00
J. Nick KostonandGitHub 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
Ville SkyttäandGitHub 3e23a3a860 Add and use bunch of data size and rate related constants (#31781)
Also fix a few units to match the corresponding data.
2020-02-13 08:52:57 -08:00