Matthias Alphart
f8f060b72b
Make util.color._match_max_scale public ( #59207 )
2021-11-10 22:29:16 -08:00
J. Nick Koston
ebb25ab0e6
Make yaml file writes safer ( #59384 )
2021-11-10 22:19:56 -08:00
Tim Rightnour
93395f9b68
Add support for PRESSURE_CBAR (centibars) ( #58762 )
...
* Add support for PRESSURE_CBAR (centibars). This is the standard UOM for tensiometers.
While the data could be converted into something like MBAR, and displayed
like that, the correct UOM for this type of sensor is CBAR. Displaying
it as MBAR would be the same as displaying air pressure as feet of Hg, while
technically correct, it's hard to understand when reading.
Adding support for this UOM will fix errors in the UI(statistics) about the unit not
matching a unit of the device_class.
* Add tests for PRESSURE_CBAR
2021-11-10 09:44:05 +01:00
rianadon
a102c425a9
Add speed conversion function & add speed to units system ( #53846 )
...
* Add speed conversion function
* Add test for speed utility functions
* Update unit system tests
* Fix incorrect unit conversions in tests
* Fix some test errors
* Calculate speed units from smaller set of constants
* Fix typo in speed test
* Use pytest.approx for checking floating point values
* Change other instance of speeds needing to be pytest.approx
* Revert changes to unit system
* Fix oopsie in defining in/day and in/hr
* Parametrize test
* Add comments describing calculations & remove duplicate test
2021-11-09 08:12:28 +01:00
J. Nick Koston
1cd9be7538
Fix recursive limit in find_next_time_expression_time ( #58914 )
...
* Fix recursive limit in find_next_time_expression_time
* Add test case
* Update test_event.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-02 00:11:17 +01:00
Otto Winter
a9c0f89c09
Fix find_next_time_expression_time ( #58894 )
...
* Better tests
* Fix find_next_time_expression_time
* Add tests for Nov 7th 2021, Chicago transtion
* Update event tests
* Update test_event.py
* small performance improvement
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-01 17:45:13 +01:00
Marc Mueller
e0c0d00833
Use assignment expressions 39 ( #58829 )
2021-10-31 18:56:25 +01:00
Ville Skyttä
b0e1bab58b
Use http.HTTPStatus in util.aiohttp ( #58456 )
2021-10-26 13:13:27 +02:00
Boris K
8b02703585
Fix color util links to Philips Hue documentation ( #57099 )
2021-10-05 11:19:09 +02:00
Glenn Waters
e4f15c42e0
Add kPa as a pressure unit ( #56885 )
2021-10-01 08:08:04 -07:00
Marc Mueller
77ee72cbb9
Import Callable from collections.abc (1) ( #56775 )
2021-09-29 16:32:11 +02:00
Marc Mueller
7af67d34cf
Use assignment expressions 01 ( #56394 )
2021-09-18 13:31:35 -10:00
Marc Mueller
b3181a0ab2
Use NamedTuple for RGBColor ( #55698 )
2021-09-04 09:25:25 +02:00
Paulus Schoutsen
19c54b8cbf
Drop unused ruamel ( #55672 )
2021-09-03 22:17:10 -07:00
Ville Skyttä
848c0be58a
Avoid some implicit generic Anys ( #54577 )
2021-08-16 23:12:06 +02:00
Daniel Hjelseth Høyer
49a69d5ba0
Add missing PRESSURE_BAR conversion ( #54497 )
...
* Add missing PRESSURE_BAR
* style
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
* valid units
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
2021-08-12 07:30:35 +02:00
Bram Kragten
e23750b2a4
Add device class `gas` and enable statistics for it ( #54110 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-08-11 09:58:19 -07:00
Marc Mueller
553521a76b
Add mixin classes for required keys in EntityDescription ( #53610 )
2021-07-28 11:50:13 +02:00
Joakim Sørensen
85c1614204
Add currency to location data ( #53575 )
2021-07-27 21:05:16 -07:00
J. Nick Koston
6d493a848c
Ensure PyPI packages can still be installed on high latency connections ( #53365 )
2021-07-24 14:07:10 +02:00
Marc Mueller
a56485a8c5
Revert new unit types ( #53226 )
2021-07-20 14:13:51 +02:00
Marc Mueller
f6b162bc39
Add pylint CodeStyle extension ( #53147 )
2021-07-19 06:57:06 -07:00
Marc Mueller
71a8ae3016
Add new unit types for better type checking ( #53124 )
...
* Add new unit types
* Update helper functions
* Update components
* Update lcn climate
2021-07-18 14:43:47 +02:00
Daniel Hjelseth Høyer
fbad453c89
Pylint 2.9.3 ( #52972 )
...
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-07-14 21:44:57 -07:00
Ville Skyttä
9864f2ef8b
String formatting cleanups ( #52937 )
2021-07-13 00:12:55 +02:00
J. Nick Koston
1ba5c1c9fb
Fix deadlock at shutdown with python 3.9 ( #52613 )
2021-07-07 09:23:24 +02:00
Erik Montnemery
b645560633
Minor improvements of util.percentage typing ( #52581 )
2021-07-06 13:29:39 +02:00
Erik Montnemery
0476c7f9ee
Normalize temperature statistics to °C ( #52297 )
...
* Normalize temperature statistics to °C
* Fix tests
* Support temperature conversion to and from K, improve tests
* Fix test
* Add tests, pylint
2021-06-30 14:17:58 +02:00
Erik Montnemery
cca5964ac0
Normalize pressure statistics to Pa ( #52298 )
2021-06-29 23:30:13 +02:00
Franck Nijhof
13bf5dbee4
Upgrade mypy to 0.902 ( #51907 )
2021-06-16 14:35:32 +02:00
Martin Hjelmare
187374c11e
Set Registry name parameter to Hashable type ( #51203 )
2021-05-28 15:29:11 +02:00
Joakim Sørensen
7ff14b47a8
Use whoami for location lookup ( #50934 )
2021-05-22 20:34:48 -07:00
Erik Montnemery
15e2c6d7dc
Fix typing for dt_util as_timestamp ( #50886 )
...
* Fix typing for dt_util::as_timestamp
* Apply suggestions from code review
2021-05-22 09:34:49 +02:00
J. Nick Koston
eddc1ab778
Handle threads exiting unexpected during shutdown ( #50907 )
...
If a thread exits right when we are trying to force an exception
to shut it down, setting the exception will fail with SystemError.
At this point in the shutdown process we want to move on as this
will cause the shutdown to abort
2021-05-21 01:06:37 +02:00
Ruslan Sayfutdinov
391b2f8ccd
Add missing return type in Core constructors ( #50884 )
2021-05-20 18:53:29 +03:00
Ruslan Sayfutdinov
de5472403b
Use mypy-friendly conditional import for zoneinfo ( #50444 )
2021-05-13 22:36:49 -07:00
Paul Ganssle
efa5c59559
Replace hand-rolled binary search with bisect_left ( #50410 )
...
The `bisect` module exposes a `bisect_left` function which does
basically what the bulk of `_lower_bound` does. From my tests, it is
slightly faster (~5%) in the probably common ideal case where `arr` is short.
In the worst case scenario, `bisect.bisect_left` is *much* faster.
```
>>> arr = list(range(60))
>>> cmp = 59
>>> %timeit _lower_bound(arr, cmp)
736 ns ± 6.24 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
>>> %timeit bisect_lower_bound(arr, cmp)
290 ns ± 7.77 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
```
I doubt this is a huge bottleneck or anything, but I think it's a bit
more readable, and it's more efficient, so it seems like it's mostly a
win.
This commit *will* add a new unconditional import for `bisect` when
importing `util.dt`, and `bisect` is not currently imported for any of
the standard library modules. It is possible to make this conditional by
placing `import bisect` in the _lower_bound function, or in the function
it's nested in.
2021-05-11 08:18:20 -07:00
Paulus Schoutsen
f8584c3ded
Use zoneinfo instead of dateutil ( #50387 )
...
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-05-10 08:32:29 -07: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
Erik Montnemery
e96cbccc92
Improve color conversion for RGBWW lights ( #49807 )
2021-04-28 15:46:41 +02:00
Ruslan Sayfutdinov
37466ae423
Don't ignore mypy errors by default ( #49270 )
2021-04-26 14:23:21 +02:00
Marc Mueller
f1d48ddfe3
Update pylint to 2.8.0 ( #49637 )
2021-04-24 14:39:24 -10:00
Marc Mueller
c07646db5d
Update typing syntax ( #49480 )
...
* Update typing syntax
* Replace typing imports with ones from collections where possible
* Changes after review
2021-04-20 17:40:41 +02:00
J. Nick Koston
04a0ca14e0
Ensure shutdown does not deadlock ( #49282 )
2021-04-18 08:55:51 -10:00
J. Nick Koston
b2c33c1373
Only fetch the local ip once per run ( #49336 )
...
Wrap get_local_ip in lru_cache
2021-04-18 10:04:45 +02:00
Ville Skyttä
3a0b0380c7
Remove some unneeded pylint disables, update ref to util.process one ( #49314 )
2021-04-17 09:25:20 +02:00
Angeliki Papadopoulou
a529a12745
Remove redundant text from documentation ( #49262 )
...
I found an extra "when" in the documentation text.
2021-04-15 18:05:07 +02:00
J. Nick Koston
d71f913a12
Ensure original log handlers are restored at close ( #49230 )
...
Error messages after close were not being logged
2021-04-15 10:53:48 +02:00
Marc Mueller
8e2b5b36b5
Bump pyupgrade to 2.12.0 ( #48943 )
2021-04-09 09:58:27 -07:00
Erik Montnemery
d1df6e6fba
Don't get code_context when calling inspect.stack ( #48849 )
...
* Don't get code_context when calling inspect.stack
* Update homeassistant/helpers/config_validation.py
2021-04-09 07:26:09 +02:00
Paulus Schoutsen
051531d9c1
Clean up mobile app ( #48607 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-04-01 16:22:08 -07:00
J. Nick Koston
f91de1c8b9
Add support for capturing renewals to dhcp discovery ( #48242 )
2021-03-30 15:41:12 +02:00
Franck Nijhof
45f77ccccf
Merge of nested IF-IF cases - Core ( #48364 )
2021-03-27 09:23:32 +01:00
J. Nick Koston
b50dcef94f
Block detectable I/O in the event loop ( #48387 )
...
We added a warning when this happens last April and gave developers
a year to fix the instability. We now prevent the instability by
raising RuntimeError when code attempts to do known I/O in the
event loop instead of the executor.
We now provide a suggestion on how to fix the code that is causing
the issue.
2021-03-27 08:54:49 +01:00
Marc Mueller
1dc25a5864
Bump python-typing-update to 0.3.2 ( #48303 )
...
* Bump python-version-update to 0.3.2
* Changes after update
* Fix pylint issues
2021-03-25 21:09:06 +01:00
J. Nick Koston
c340a39275
Handle range conversions that do not start at 1 ( #48298 )
2021-03-24 12:33:44 -10:00
Franck Nijhof
6932cf9534
Use contextlib.suppress where possible ( #48189 )
2021-03-23 14:36:43 +01:00
Franck Nijhof
fb849b81b5
Rewrite of not a == b occurances ( #48132 )
2021-03-20 01:27:04 +01:00
J. Nick Koston
c820dd4cb5
Have pylint warn when user visible log messages do not start with capital letter or end with a period ( #48064 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-03-19 09:26:36 -05:00
Franck Nijhof
8a56dbf587
Add flake8 comprehensions checks to pre-commit & CI ( #48111 )
2021-03-19 13:41:09 +01:00
Marc Mueller
fabd73f08b
Update typing 03 ( #48015 )
2021-03-17 21:46:07 +01:00
Paulus Schoutsen
7fe3c472e9
Improve bad JSON data reporting ( #47932 )
...
* Improve bad data reporting
* Fix tests
Co-authored-by: Erik <erik@montnemery.com>
2021-03-15 10:41:25 +01:00
J. Nick Koston
9a686d148e
Ensure startup can proceed when there is package metadata cruft ( #47706 )
...
If a package fails to install or partially installed importlib
version can return None. We now try pkg_resources first, then
try importlib, and handle the case where version unexpectedly
returns None
2021-03-10 21:12:02 -10:00
Shay Levy
215ab5fd40
Add type hints to LightEntity ( #47024 )
2021-03-08 21:21:45 +01:00
Franck Nijhof
208a104e96
Fix secrets in files included via include_dir_list ( #47350 )
2021-03-04 09:33:35 -08:00
Paulus Schoutsen
2df644c6cc
Clean up secret loading ( #47034 )
2021-03-02 12:58:53 -08: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
86f8cd8037
Provide a human readable exception for the percentage util ( #47121 )
2021-02-26 16:33:13 -08:00
Paulus Schoutsen
633a7aeb22
Remove deprecated credstash + keyring ( #47033 )
2021-02-25 09:48:19 +01:00
Franck Nijhof
6ad7020f99
Add Home Assistant color ( #46751 )
2021-02-19 13:30:27 +01:00
J. Nick Koston
f2b303d509
Implement percentage step sizes for fans ( #46512 )
...
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-02-18 21:05:09 -10:00
Tom Parker-Shemilt
27d16af36b
Don't allow recursive secrets loading ( #41812 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-02-14 14:23:31 +01:00
Franck Nijhof
9b7c39d20b
Postponed evaluation of annotations in core ( #46434 )
...
* Postponed evaluation of annotations in core
* Remove unneeded future
2021-02-12 10:58:20 +01:00
Erik Montnemery
fb68bf85ae
Don't defer formatting of log messages ( #44873 )
...
* Make fast logging optional
* Remove fast logging support
2021-02-06 13:40:15 +01:00
J. Nick Koston
9f59515bb8
Fix shutdown deadlock with run_callback_threadsafe ( #45807 )
2021-02-01 10:54:39 +01:00
Ville Skyttä
d13b58a4e6
Upgrade mypy to 0.800 ( #45485 )
...
* Upgrade mypy to 0.800
https://mypy-lang.blogspot.com/2021/01/mypy-0800-released.html
* Fix issues flagged by mypy 0.800
* Add overloads + small changes
* Apply grammar
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-01-30 22:33:53 +01:00
J. Nick Koston
068d1b5eb8
Separate fan speeds into percentages and presets modes ( #45407 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: John Carr <john.carr@unrouted.co.uk>
2021-01-27 17:44:36 -06:00
Thomas Hollstegge
78b057ce02
Make sure generated slugs are not empty ( #43153 )
2021-01-27 12:25:49 +01:00
Joakim Sørensen
b1c2cde40b
Changes to filename and path validation ( #45529 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-01-26 15:53:21 +01:00
Paulus Schoutsen
0930aae208
Avoid misuse sanitize_path, clarify docs ( #45469 )
2021-01-23 18:28:57 +01:00
Ville Skyttä
94dbcc9d2b
Generics and other type hint improvements ( #45250 )
2021-01-18 22:23:25 +01:00
Pascal Vizeli
a7a4875f52
Add more debug details to running timeouts ( #43644 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-01-04 13:10:39 +01:00
Ville Skyttä
43474762b2
Drop remaining Python < 3.8 support ( #44743 )
...
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-01-04 11:47:29 +01:00
Franck Nijhof
2f486543df
Drop Python 3.7 support ( #43805 )
2021-01-01 13:47:01 +01:00
Paulus Schoutsen
58648019c6
Deprecate the use of keyring and credstash ( #43854 )
2020-12-02 16:55:33 +01:00
Paulus Schoutsen
1c9c99571e
Use !input instead of !placeholder ( #43820 )
...
* Use !input instead of !placeholder
* Update input name
* Lint
* Move tests around
2020-12-01 18:21:36 +01:00
Paulus Schoutsen
edf70e9f06
Make input_datetime better handle timezones ( #43396 )
...
* Make input_datetime better handle timezones
* Improve test coverage
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Revert change to time format
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-11-26 20:20:10 +01:00
springstan
37bcfd1d2f
Simplify distance conversion ( #43107 )
2020-11-11 20:10:17 +01:00
J. Nick Koston
94bf55e29b
Limit concurrency of async_get_integration to avoid creating extra threads ( #43085 )
...
* Limit concurrency of async_get_integration to avoid creating extra threads
Since async_get_integration is waiting on the disk most of the time
it would end up creating many new threads because the disk could
not deliver the data in time.
* pylint
2020-11-10 21:34:54 -10:00
springstan
67b3552165
Add more units to distance conversion util ( #40181 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-11-09 11:38:15 +01:00
Paulus Schoutsen
0fb587727c
Add initial blueprint support ( #42469 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2020-11-02 15:00:13 +01:00
Philip Allgaier
dde6305549
Cleanup unused loggers (components N-Z + tests) ( #41982 )
2020-10-16 21:24:08 -05:00
Ville Skyttä
f28c3273c2
Upgrade mypy to 0.790 ( #41595 )
2020-10-12 19:17:30 -05:00
J. Nick Koston
a9de9c62f1
Use native utc timezone for utcnow() ( #41727 )
...
This allows timezone operations to happen in C code instead
of the pure-python code of pytz
2020-10-12 17:43:21 -05:00
Dmitry
b106149588
Fix string parameter processing in parse_time_expression ( #41468 ) ( #41469 )
2020-10-09 11:48:49 +02:00
J. Nick Koston
8d5c124deb
Improve performance of generating non-cryptographically secure uuids ( #41314 )
2020-10-07 16:37:01 +02:00
springstan
a2c3c33b22
Use core GitHub URL in all files ( #41089 )
2020-10-03 00:04:11 +02:00
J. Nick Koston
e08ee282ab
Abort execution of template renders that overwhelm the system ( #40647 )
2020-09-28 14:43:22 +02:00
Bjørn Snoen
f207d46390
Allow using environment cacert file ( #38816 )
2020-09-04 13:54:20 +02:00
Ville Skyttä
1bf2c4d976
Upgrade pylint to 2.6.0 ( #39363 )
2020-08-29 07:59:24 +02:00