Commit graph

51 commits

Author SHA1 Message Date
Anton Tolchanov 80f8e76fa3
Handle attributes set to None in prometheus (#104247)
Better handle attributes set to None
2023-11-20 19:53:25 +01:00
Max 1e57bc5415
Add number state to prometheus metrics (#102518) 2023-11-13 17:03:08 +01:00
Sam Crang b2b57c5f87
Allow exporting of update domain to Prometheus (#99400) 2023-09-07 20:43:47 -07:00
Russell Cloran 9144ef7ed8
Enumerate available states in Prometheus startup (#97993) 2023-09-04 09:30:56 +02:00
Russell Cloran 5fd14eade5
Handle timestamp sensors in Prometheus integration (#98001) 2023-09-02 10:20:36 +02:00
Russell Cloran 49995a4667
Add tests for device tracker in Prometheus (#98054) 2023-08-17 17:58:52 +02:00
Jadson Santos f6273bfca5
Add prometheus requires_auth parameter (#92964)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-08-08 12:15:08 +02:00
J. Nick Koston dc5ee71d7a
Add slots to core EventBus (#95856) 2023-07-05 11:47:24 -05:00
J. Nick Koston c63e3c3bf1
Update prometheus tests to avoid patching utcnow (#93505) 2023-05-25 07:15:14 +02:00
epenet d65dff3f9e
Adjust entity registry access in tests (2) (#88960) 2023-03-01 16:23:36 +01:00
epenet 2cdc741900
Add type hints to integration tests (part 17) (#88163) 2023-02-15 11:14:04 +01:00
Michael 72d3fa6d89
Replace the usage of unit constants by enumerations in Tests [o-r] (#85936) 2023-01-15 14:50:24 +01:00
Matt Gerega 2215adf5cf
Add support for covers in Prometheus metrics (#83763)
fixes undefined
2022-12-27 11:25:33 +01:00
Michael 8a3fc2e82b
Fix attribute check in prometheus exporter (#84321)
* fix attribute check

* add test
2022-12-20 16:32:00 -08:00
epenet f453726b18
Cleanup HVACAction and HVACMode in tests (#78813) 2022-09-20 20:30:54 +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
Paulus Schoutsen 5eb19b8a70
Enforce RegistryEntryDisabler enum (#69017)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-03-31 13:10:07 -07:00
alim4r ca469750ac
Prometheus tests simulate entities (#64916) 2022-01-27 15:56:12 +01:00
alim4r 3e0e9e54bf
Fix duplicate metrics in prometheus (#61355)
* Fix duplicate metrics in prometheus

* Fix duplicate prometheus metrics for entities with multiple labelsets
- Move friendly_name detection to state_changed event
- Add additional test case

* Add review suggestions for prometheus friendly name update

* Remove commented out code in prometheus

* Update prometheus tests for deleted metrics

* Add review suggestions for prometheus
- Remove unnecessary firendly_name check in handle_entity_registry_updated
- Add assert in test
2022-01-25 08:05:52 -08:00
Renat Nurgaliyev d11f2b5151
Add HVAC modes of climate entities to Prometheus exporter (#62144) 2022-01-19 14:49:29 +01:00
Jevgeni Kiski 6af99882c5
Prometheus to support input_number (#58964)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2022-01-04 18:52:43 +01:00
Renat Nurgaliyev f71d49230d
Add counter entities support to Prometheus component (#62410) 2022-01-04 17:34:05 +01:00
Dave T 38e95ca663
Use new enums for prometheus tests (#62550) 2021-12-22 14:31:20 +01:00
alim4r 7d256f56c5
Refactor Prometheus tests (#60451)
* Removed prometheus from .coveragerc

* Update prometheus tests with handler categories

* Updated prometheus metrics to use the current registry
- don't use the registry created on import (needed for tests)

* Reset the prometheus CollectorRegistry before every test

* Update prometheus metrics generation
- Use latest registry when generating a response

* Add default collectors when resetting the registry

* Move entities to the specific prometheus test case

* Refactor body generation for prometheus tests

* Add test case for sensors without unit after rebase

* Fix prometheus tests
- Wait for events in prometheus tests
- Add workaround for demo platform dependecy conversation (aiohttp frozen router)

* Added prometheus tests for attribute metrics

* Added prometheus tests for binary_sensor

* Add prometheus test for input_boolean

* Add prometheus test for lights

* Add prometheus test for lock

* Add prometheus test for sensor fahrenheit conversion

* Fix prometheus test for input_number
2021-12-08 20:18:21 +01:00
Erik Montnemery 5169ee69c7
Attempt to fix flaky prometheus test (#61242) 2021-12-08 16:08:02 +01:00
alim4r 42389fc81b
Support numeric sensors with no unit_of_measurement in prometheus (#60157) 2021-11-24 22:30:08 +01:00
alim4r e180f1e302
Add input_number state to prometheus metrics (#56507)
* Add input_number to prometheus metrics

* Add prometheus input_number tests

* Removed unused import from test
2021-11-17 19:35:48 -08:00
Ville Skyttä 380cff167e
Use HTTPStatus in components/[nop]* (#58279) 2021-10-23 20:56:30 +02:00
Matt Zimmerman 515a47212e
Add target high/low temperatures to prometheus integration (#50071)
* add target high/low temperatures to prometheus integration

* use labels

* Revert "use labels"

This reverts commit 09c56d6359.

* fix naming

* tests

* cleanup

* use three separate metrics

* fix descriptions
2021-08-04 07:42:47 +02:00
Anton Tolchanov 80aaebb761
Rename Prometheus metrics to conform with naming guidelines (#50156) 2021-07-26 20:52:30 +02:00
Erik Montnemery 216b0df908
Set state_class for demo sensor (#50523) 2021-05-12 18:38:26 +02:00
Franck Nijhof 5a2b5fe7c5
Yoda assertion style removed is (#48142) 2021-03-20 13:55:10 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
springstan 0c077685b6
Use content type text plain constant (#40313) 2020-09-20 13:19:10 +02:00
Eric Severance 16a947aa5f
Add generic unavailable and last_updated metrics for prometheus (#37456)
* Add generic unavailable and last_updated metrics for prometheus

* Updated with feedback from the code review
2020-07-12 21:27:33 +02:00
Shulyaka 872140123d
Add humidifier support to prometheus (#37112)
* Add humidifier support to promethease

* add humidifier dependency

* handle dependencies

* wrong place

* applied suggestions from code review

* fix typo

* Revert "wrong place"

This reverts commit 58e509d767.

* Revert "handle dependencies"

This reverts commit 74bd523e08.

* Revert "add humidifier dependency"

This reverts commit 8840b378e5.
2020-07-08 20:42:45 -04:00
mdegat01 b78f163bb0
Changed FilterTest namedtuples to dataclasses (#37252) 2020-06-30 11:59:21 -05:00
mdegat01 6c7355785a
Add support for glob matching to entity filters (#36913)
* Added GLOB capability to entityfilter and every place that uses it. All existing tests are passing

* added tests for components affected by glob change

* fixed flake8 error

* mocking the correct listener

* mocking correct bus method in azure test

* tests passing in 3.7 and 3.8

* fixed formatting issue from rebase/conflict

* Checking against glob patterns in more performant way

* perf improvments and reverted unnecessarily adjusted tests

* added new benchmark test around filters

* no longer using get with default in entityfilter

* changed filter name and removed logbook from filter benchmark

* simplified benchmark tests from feedback

* fixed apache tests and returned include exclude schemas to normal

* fixed azure event hub tests to properly go through component logic

* fixed azure test and clean up for other tests

* renaming test files to match standard

* merged mqtt statestream test changes with base

* removed dependency on recorder filter schema from history

* fixed recorder tests after merge and a bunch of lint errors
2020-06-23 20:02:29 -05:00
Paulus Schoutsen 276f3afb00
Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-31 22:18:30 -07:00
springstan ef9d9b17bd
Drop UNIT_ prefix for constants (#34164)
* Drop UNIT_ prefix for VOLT

* Drop UNIT_ prefix for DEGREE

* Drop UNIT_ prefix for CONDUCTIVITY

* Drop UNIT_ prefix for UV_INDEX

* Run isort
2020-04-21 19:45:53 +02:00
springstan b893150154
Add and use UNIT_DEGREE constant (#33978)
* Add and use UNIT_DEGREE constant

* Replace more occurrences

* Add and use TEMP_KELVIN

* Run isort
2020-04-11 16:54:11 +02:00
springstan 02c9e47db8
Use ENERGY_KILO_WATT_HOUR constant (#33962) 2020-04-10 20:21:29 +02:00
Ville Skyttä 496bd3dddf
Add and use more unit constants (#32122)
* Add and use speed constants

* Add and use meter based volume and area constants

* Add and use more mass unit constants

* Add and use concentration unit constants

* Add and use watts per square meter constant

* Use more time constants

* Use more data constants
2020-02-24 17:52:14 -08:00
Joe Gross 3b4c3e6e17 Fix prometheus component to fully sanitize Unicode characters (#31037)
* Fix prometheus component to fully santize Unicode characters.

Sanitization used isdigit() to match numerics but that also matches 
Unicode "digit" characters that require special handling, like 
superscripts. Failures would look like this:

ValueError: Invalid metric name: sensor_unit_u0x23_per_m³

Changed sanitize to use string.digits, which matches only ascii digits, 
and added test.

See 
https://stackoverflow.com/questions/44891070/whats-the-difference-between-str-isdigit-isnumeric-and-isdecimal-in-python 
for discussion.

https://docs.python.org/3/library/stdtypes.html#str.isdigit

https://docs.python.org/3.7/library/string.html#string.digits

* fix formatting to comply with black
2020-01-22 01:03:42 +01:00
Franck Nijhof e642d95d0f Migrate collection of component tests from coroutine to async/await (#30504) 2020-01-06 01:22:22 +01:00
Bas Nijholt 21816eeed4 Sort imports according to PEP8 for components starting with "P" (#29775) 2019-12-09 14:29:39 +01:00
Bram Kragten 15e6278a2e
Add config entry and device support to Demo (#28702)
* Add config entry and device support to Demo

* Some more devices

* Fix tests using demo

* Review comments

* Update config_flow.py

* Revert

* Disable pylint
2019-11-13 16:37:31 +01:00
Andrew Rowson 770eeaf82f Encode prometheus metric names per the prom spec (#26639)
Referencing issue #26418.

Prometheus metric names can only contain chars a-zA-Z0-9, : and _
(https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels).

HA currently generates invalid prometheus names, e.g. if the unit for a
sensor is a non-ASCII character containing  ° or μ. To resolve, we need
to sanitize the name before creating, replacing non-valid characters
with a valid representation. In this case, I've used
"u{unicode-hex-code}".

Also updated the test case to make sure that the ° case is handled.
2019-09-19 12:51:49 +02:00
Per Osbäck e9705af055 Prometheus metrics naming based on device_class and unit_of_measurement (#24103)
* - Change how we extract the metrics for sensors
- Add component filtering as seen in influxdb
- Add metric override as seen in influxdb
- Add more unit tests with actual device data

* Extract sensor metric logic to separate handlers

* Update prometheus dependency

* Format using black

* Format using black

* Fix flake8

* Move sensor metric handler list to init

* Use f strings instead of .format
2019-08-10 14:35:04 +02:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00