Erik Montnemery
f93bbd55ba
Improve logging shutdown ( #85812 )
...
* Improve logging shutdown
* Update test
2023-01-17 20:06:25 +01:00
Erik Montnemery
b0d4b73874
Add unitless unit converter ( #85694 )
...
* Add unitless unit converter
* Adjust type hints
* Adjust tests
* Rename to UnitlessRatioConverter
2023-01-12 09:20:00 +01:00
Franck Nijhof
7adb8d5ddc
Code styling tweaks to core utils & YAML loader ( #85433 )
...
Code styling tweaks to core utils
2023-01-08 22:01:55 -08:00
J. Nick Koston
d81febd3f4
Small speed up to frequently called datetime functions ( #85399 )
2023-01-08 09:42:29 -10:00
SukramJ
005bc8994d
Add mA to SensorDeviceClass.CURRENT units ( #84492 )
...
fixes undefined
2022-12-30 13:55:14 +01:00
Jan Bouwhuis
b2388b74d9
Add mV as a unit for voltage and enable conversions ( #84805 )
...
fixes undefined
2022-12-30 12:51:05 +01:00
epenet
6261994fcf
Enable unit conversion for DATA_SIZE ( #84699 )
2022-12-29 09:58:15 +01:00
epenet
46e02ebaff
Enable unit conversion for DATA_RATE ( #84698 )
2022-12-28 21:49:00 +01:00
Franck Nijhof
d4f69a3652
String formatting and max line length - Part 7 ( #84532 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-27 11:18:56 +01:00
Marc Mueller
19acbf0d2a
Update types packages ( #84381 )
2022-12-21 19:15:55 +01:00
epenet
d6fc2d9452
Prevent use of deprecated units ( #83384 )
...
* Prevent use of deprecated units
* Adjust obsolete util
* More units
* Add FREQUENCY
* Adjust pylint ignore
* Add ELECTRIC (current/potential)
* Add TIME
* Adjust units
2022-12-21 15:24:11 +01:00
Michaël Arnauts
7142b4ecac
Fixes some grammar mistakes ( #84283 )
2022-12-20 11:10:31 +01:00
epenet
f4c13645d2
Add support for CCF volume unit ( #84029 )
2022-12-19 14:57:04 +01:00
epenet
4a848e8222
Add stones to mass units ( #83933 )
2022-12-13 17:35:14 +01:00
Marc Mueller
0e95875912
Improve ignore_variance typing ( #83927 )
2022-12-13 15:22:23 +01:00
epenet
583b4aef07
Enable automatic conversion for pressures ( #83525 )
...
* Enable automatic conversion between bar and psi
* Fix tests
* Fix mazda tests
* Fix oncue tests
* Adjust US pressures
* Adjust metric pressures
* Adjust tests
* Adjust tests
2022-12-12 12:42:35 +01:00
epenet
b172abaeeb
Add new atmospheric pressure device class ( #83455 )
...
* Add new atmospheric pressure device class
* Translations
* Automatic conversion
* Convert all pressure units
2022-12-09 08:02:53 +01:00
epenet
91d6d620c2
Use new unit enums in alexa ( #83409 )
...
* Use new unit enums in alexa
* Adjust for mypy
2022-12-06 17:31:40 +01:00
epenet
eb13f2b724
Use UnitOfVolume in unit conversion ( #83292 )
2022-12-05 16:56:05 +01:00
epenet
4ad9633dfb
Use new unit enums in weather entity ( #82937 )
2022-11-29 18:10:31 +01:00
epenet
dd960c4e62
Add precipitation device class ( #81145 )
2022-11-18 12:41:33 +01:00
Aarni Koskela
8038485ca4
Use partition instead of split where possible in core ( #81806 )
2022-11-15 21:45:48 +01:00
Aarni Koskela
fa9a51e528
Use os.path.dirname() for getting the directory name of a path ( #81504 )
2022-11-14 15:21:35 +01:00
Marc Mueller
0c8eeaa643
Update mypy to 0.990 ( #81783 )
...
* Update mypy to 0.990
* Remove type ignore - overriding attr with property (13475)
* Remove type ignores - hasattr (13544)
* Adjust type ignore - assignment (13549)
* New error code - type-abstract (13785)
* Disable annotation-unchecked (13851)
2022-11-08 14:41:39 +01:00
J. Nick Koston
1589c06203
Significantly reduce clock_gettime syscalls on platforms with broken vdso ( #81257 )
2022-10-31 09:35:08 -04:00
epenet
2a2e097e17
Use unit enums in unit utilities ( #81030 )
2022-10-26 20:47:17 +02:00
epenet
842cb18d39
Migrate energy units to an enum ( #80998 )
2022-10-26 13:56:51 +02:00
Erik Montnemery
352976fd1d
Add rules for converting volumes ( #80951 )
...
* Add rules for converting volumes
* Use SensorDeviceClass in new tests
* Tweak tests
* Update flo tests
* Update sensor tests
2022-10-26 10:29:33 +02:00
epenet
7838bb3ebe
Replace new PRECIPITATION_INTENSITY with enum ( #80653 )
2022-10-25 16:45:45 +02:00
Erik Montnemery
727eccfec4
Add GJ as supported unit for energy sensors ( #80870 )
...
* Add GJ as supported unit for energy sensors
* Update homeassistant/const.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-10-25 16:43:00 +02:00
epenet
0018939142
Adjust unit_system type hints ( #80946 )
2022-10-25 15:56:18 +02:00
Erik Montnemery
b07e1281da
Add rules for converting speeds ( #80943 )
...
* Add rules for converting speeds
* Update metoffice wind speed sensors to prefer mph
* Don't convert speeds measured in knots
2022-10-25 14:53:59 +02:00
Erik Montnemery
aea0067e49
Add additional rules for converting distances ( #80940 )
...
* Add additional rules for converting distances
* Convert in to mm
* Adjust existing tests
* Add test
2022-10-25 12:51:23 +02:00
Erik Montnemery
6979cd95b0
Add suggested_unit_of_measurement attribute to sensors ( #80638 )
...
* Add suggested_unit_of_measurement attribute to sensors
* Lazy calculation of initial entity options
* Add type alias for entity options
* Small tweak
* Add tests
* Store suggested_unit_of_measurement in its own option key
* Adapt to renaming of IMPERIAL_SYSTEM
* Fix rebase mistakes
* Apply suggestions from code review
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-10-24 16:08:02 +02:00
epenet
8a1cc05e0c
Enforce kwargs in unit system initialisation ( #80620 )
...
* Enforce kwargs in unit system initialisation
* Fix tests
* Sort kwargs in unit_system
2022-10-20 10:43:32 +02:00
epenet
9afb4c6c9e
Adjust precipitation units ( #79780 )
...
* Adjust precipitation units
* Use PRECIPITATION_INTENSITY
* Revert isy994
* Adjust SensorDeviceClass docstring
* Adjust comment
2022-10-19 14:35:49 +02:00
epenet
67d1dde69f
Rename IMPERIAL_SYSTEM to US_CUSTOMARY_SYSTEM ( #80253 )
...
* Rename IMPERIAL_SYSTEM
* Deprecate is_metric property and adjust tests
* Adjust unit_system config validation
* Add yaml tests
* Add tests for private name
* Fix incorrect rebase
* Adjust docstring
* Add store migration
* Update unit_system.py
* Minimise test tweaks
* Fix tests
* Add conversion to migration
* Rename new key and adjust tests
* Adjust websocket_detect_config
* Move original_unit_system tracking to subclass
2022-10-19 13:31:08 +02:00
epenet
bff5d1123f
Deprecate CONF_UNIT_SYSTEM_*** constants ( #80320 )
...
* Deprecate CONF_UNIT_SYSTEM_*** constants
* Adjust pylint plugin
* Add tests
* Remove single-use function
* Revert logic change
* Revert "Revert logic change"
This reverts commit 60959a0050
.
* Tweak again
2022-10-14 16:50:04 +02:00
epenet
6a757662e4
Deprecate is_metric property of unit system ( #80313 )
2022-10-14 13:44:18 +02:00
epenet
4dd0c079d5
Deprecate name property of unit system ( #80257 )
2022-10-14 12:06:14 +02:00
G Johansson
4cf0f9b197
Fix incorrect deprecation year for conversion utils ( #80195 )
...
Fix incorrect depr year
2022-10-13 00:06:23 +02:00
epenet
aa0bb9c3d2
Improve precision in pressure conversion ( #79362 )
...
* Improve precision in pressure conversion
* Use _STANDARD_GRAVITY
* Add again pytest.approx
2022-10-06 12:48:31 +02:00
Erik Montnemery
47d0598e75
Use Kelvin as the preferred color temperature unit ( #79591 )
...
* Use Kelvin as the preferred white temperature unit
* Update homekit
* Adjust tests
2022-10-06 12:22:39 +02:00
epenet
825f9502ad
Align temperature conversion with other converters ( #79521 )
...
* Align temperature conversion with other converters
* Add comments and docstring
* Align tests
2022-10-03 10:09:55 +02:00
epenet
b649ef8d87
Realign util constants with 2022.9.7 ( #79357 )
2022-09-30 14:38:11 -04:00
epenet
ac7b4e7569
Make temperature conversions private ( #79349 )
2022-09-30 11:07:10 +02:00
epenet
9c3b40dad1
Deprecate conversion utilities ( #78957 )
...
* Deprecate utilities
* Deprecate distance and speed
* Add tests
* Adjust pylint
* Simplify temperature deprecation
2022-09-28 19:39:44 +02:00
epenet
253647aaa9
Use unit_conversion in unit_system utility ( #79004 )
2022-09-28 14:37:22 +02:00
epenet
5438552d4a
Cleanup unit conversion ( #79197 )
...
* Move UNIT_RATIO to BaseUnitConverter
* Make UNIT_CONVERSION private
* Remove STATISTIC_UNIT_TO_UNIT_CLASS constant
* Cleanup websocket_api
* Imrpove valid_units check
2022-09-28 13:49:46 +02:00
epenet
5389ff3253
Add new weight device class ( #79185 )
2022-09-28 12:13:49 +02:00
epenet
c96c5bed7d
Remove argument validation in Unit Converter ( #79107 )
...
* Remove argument validation in Unit Converter
* Use HomeAssistantError
* Adjust tests
* Improve coverage
2022-09-28 10:58:04 +02:00
epenet
dc82ae4f69
Make VALID_UNITS a set ( #79104 )
...
* Make VALID_UNITS a set
* Also adjust weather
2022-09-27 07:16:03 +01:00
epenet
4200778eaf
Move distance and speed util to unit_conversion ( #78967 )
2022-09-23 08:23:59 -04:00
epenet
9692cdaf2d
Make _is_valid_unit private in unit system ( #78924 )
2022-09-22 21:02:31 +02:00
epenet
ddf56baf7a
Move temperature utility to unit_conversion ( #78960 )
2022-09-22 18:31:50 +02:00
epenet
c8491c4404
Move volume utility to unit_conversion ( #78955 )
...
* Move volume utility to unit_conversion
* Split tests
2022-09-22 17:49:45 +02:00
epenet
523d8d246b
Move pressure utility to unit_conversion ( #78953 )
2022-09-22 16:44:09 +02:00
epenet
0767cdd935
Move energy and power utilites to unit_conversion ( #78950 )
...
* Move energy and power utilites to unit_conversion
* Move tests
2022-09-22 15:39:49 +02:00
epenet
6002377d4f
Convert UnitConverter protocol to a class ( #78934 )
...
* Convert UnitConverter protocl to a class
* Remove logic change
* Use TypeVar
* Remove NORMALIZED_UNIT from pressure
* Reduce size of PR
* Reduce some more
* Once more
* Once more
* Remove DEVICE_CLASS
2022-09-22 14:15:22 +02:00
epenet
713fb874a8
Add NORMALISED_UNIT to UnitConverter ( #78920 )
...
* Add NORMALISED_UNIT to UnitConverter
* Adjust statistics
* Rename
2022-09-22 08:50:08 +02:00
epenet
39315b7fe3
Introduce UnitConverter protocol ( #78888 )
...
* Introduce ConversionUtility
* Use ConversionUtility in number
* Use ConversionUtility in sensor
* Use ConversionUtility in sensor recorder
* Add normalise to ConversionUtility
* Revert changes to recorder.py
* Reduce size of PR
* Adjust recorder statistics
* Rename variable
* Rename
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-09-22 07:18:00 +02:00
epenet
ca78b1a77d
Add new energy utility ( #78883 )
...
* Add new energy utility
* Adjust STATISTIC_UNIT_TO_VALID_UNITS
2022-09-21 19:40:40 +02:00
epenet
d7382aadfe
Add new power utility ( #78867 )
...
* Add power utility
* Fix tests
2022-09-21 14:48:38 +02:00
epenet
9e7c03af56
Use m3 as intermediate unit for volume conversions ( #78861 )
...
* Use m3 as SI volume standard unit
* Adjust comment
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-09-21 12:37:31 +02:00
Jan Bouwhuis
35221e9a61
Correct return typing for `catch_log_exception` ( #78399 )
2022-09-17 17:27:22 +02:00
Artem Draft
29be6d17b0
Add is_host_valid util ( #76589 )
2022-09-11 11:12:04 -05:00
epenet
9490771a87
Refactor distance, speed and volume utils ( #77952 )
...
* Refactor distance util
* Fix bmw connected drive tests
* Adjust here travel time tests
* Adjust waze travel time tests
* Adjust test_distance
* Adjust rounding values
* Adjust more tests
* Adjust volume conversions
* Add tests
2022-09-07 16:18:00 +02:00
Paulus Schoutsen
481205535c
Add PrusaLink integration ( #77429 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-08-29 20:45:27 -04:00
J. Nick Koston
a628be4db8
Only stat the .dockerenv file once ( #76097 )
2022-08-02 10:38:01 -10:00
Marc Mueller
81d1786a16
Remove unused logging args parameter ( #75619 )
2022-08-01 10:13:05 +02:00
J. Nick Koston
48e82ff62f
Fix failure to raise on bad YAML syntax from include files ( #75510 )
...
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2022-07-20 19:25:17 +02:00
Franck Nijhof
7adb0f0ef5
Custom component -> Custom integration ( #75404 )
2022-07-18 22:10:22 +02:00
J. Nick Koston
9a27f1437d
Use default encoder when saving storage ( #75319 )
2022-07-17 14:25:19 +02:00
henryptung
7d27dad190
Remove pip --prefix workaround ( #74922 )
...
Remove --prefix workaround
See discussion in https://github.com/home-assistant/core/issues/74405 .
This workaround is no longer needed on pip >= 21.0 and actively causes problems for pip >= 21.3.
2022-07-11 11:33:28 +02:00
Franck Nijhof
52130b227e
Update flake8-comprehensions to 3.10.0 ( #74882 )
2022-07-10 14:55:43 +02:00
J. Nick Koston
8d0e54d776
Use the orjson equivalent default encoder when save_json is passed the default encoder ( #74377 )
2022-07-04 08:41:23 -05:00
Erik Montnemery
d3f4108a91
Support knots and ft/s in weather wind speed ( #74175 )
2022-06-29 16:34:41 +02:00
Erik Montnemery
c186a73e57
Tweak speed util ( #74160 )
2022-06-29 12:01:09 +02:00
[pʲɵs]
91a119917d
List more private and link-local IP networks ( #74064 )
...
List more private and link-local IP networks
The IPv6 link-local network is especially important as without it
local accounts don't work on IPv6-capable networks with no IPv6 DHCP
server.
2022-06-27 22:00:44 -07:00
J. Nick Koston
1866a1e925
Handle non-str keys when storing json data ( #73958 )
2022-06-24 09:59:01 -05:00
J. Nick Koston
2f78faa718
Make aiohttp mockers aware of the json loads kwarg ( #73939 )
2022-06-24 08:44:35 +02:00
J. Nick Koston
fd9fdc6283
Fix error reporting with unserializable json ( #73908 )
2022-06-23 20:32:45 +02:00
J. Nick Koston
8b067e83f7
Initial orjson support take 3 ( #73849 )
...
* Initial orjson support take 2
Still need to work out problem building wheels
--
Redux of #72754 / #32153 Now possible since the following is solved:
ijl/orjson#220 (comment)
This implements orjson where we use our default encoder. This does not implement orjson where `ExtendedJSONEncoder` is used as these areas tend to be called far less frequently. If its desired, this could be done in a followup, but it seemed like a case of diminishing returns (except maybe for large diagnostics files, or traces, but those are not expected to be downloaded frequently).
Areas where this makes a perceptible difference:
- Anything that subscribes to entities (Initial subscribe_entities payload)
- Initial download of registries on first connection / restore
- History queries
- Saving states to the database
- Large logbook queries
- Anything that subscribes to events (appdaemon)
Cavets:
orjson supports serializing dataclasses natively (and much faster) which
eliminates the need to implement `as_dict` in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized. I audited all places where we have an `as_dict`
for a dataclass and found only backups needs to be adjusted (support for `Path` needed to be added for backups). I was a little bit worried about `SensorExtraStoredData` with `Decimal` but it all seems to work out from since it converts it before it gets to the json encoding cc @dgomes
If it turns out to be a problem we can disable this
with option |= [orjson.OPT_PASSTHROUGH_DATACLASS](https://github.com/ijl/orjson#opt_passthrough_dataclass ) and it
will fallback to `as_dict`
Its quite impressive for history queries
<img width="1271" alt="Screen_Shot_2022-05-30_at_23_46_30" src="https://user-images.githubusercontent.com/663432/171145699-661ad9db-d91d-4b2d-9c1a-9d7866c03a73.png ">
* use for views as well
* handle UnicodeEncodeError
* tweak
* DRY
* DRY
* not needed
* fix tests
* Update tests/components/http/test_view.py
* Update tests/components/http/test_view.py
* black
* templates
2022-06-22 21:59:51 +02:00
J. Nick Koston
034c0c0593
Improve YAML Dump times with C Dumper ( #73424 )
2022-06-13 13:14:30 -07:00
J. Nick Koston
dca4d3cd61
Significantly improve yaml load times when the C loader is available ( #73337 )
2022-06-13 08:44:46 -10:00
J. Nick Koston
c365454afb
Revert "Initial orjson support ( #72754 )" ( #72789 )
...
This was causing the wheels to fail to build. We need
to workout why when we don't have release pressure
This reverts commit d9d22a9556
.
2022-05-31 13:51:55 -07:00
J. Nick Koston
d9d22a9556
Initial orjson support ( #72754 )
2022-05-31 12:18:11 -07:00
Marc Mueller
3c246b7800
Update mypy to 0.960 ( #72481 )
2022-05-25 11:42:14 -07:00
Kevin Stillhammer
90e5d69184
Add template as_timedelta ( #71801 )
2022-05-23 19:32:22 +02:00
J. Nick Koston
4e9bc9eaff
Small cleanups to find_next_time_expression and addition of tests ( #71845 )
2022-05-14 12:13:32 -07:00
J. Nick Koston
ebce5660e3
Sync event timed_fired and the context ulid time ( #71854 )
2022-05-14 12:12:08 -07:00
J. Nick Koston
222baa53dd
Make database access in the eventloop raise an exception ( #71547 )
2022-05-09 15:22:08 -05:00
J. Nick Koston
2a9f043039
Use ULID short format for context ids ( #71119 )
2022-05-01 21:44:54 -07:00
Marc Mueller
9a3908d21d
Improve typing [util.logging] ( #70894 )
2022-04-27 22:26:56 +02:00
Marc Mueller
02ddfd513a
Improve typing [util.location] ( #70893 )
2022-04-27 17:20:56 +02:00
Marc Mueller
97af164858
Prepare for upcoming mypy update ( #70800 )
2022-04-26 07:41:52 -07:00
J. Nick Koston
d03760d0bb
Switch to using ULIDs for context_ids ( #70246 )
2022-04-18 22:45:41 -07:00
Erik Montnemery
91f6e58e9a
Allow customizing unit for temperature and pressure sensors ( #64366 )
...
* Allow customizing unit for temperature and pressure sensors
* pylint
* Adjust google_wifi tests
* Address review comments and add tests
* Improve rounding when scaling
* Tweak rounding
* Further tweak rounding
* Allow setting entity options with config/entity_registry/update
* Address review comments
* Tweak tests
* Load custom unit when sensor is added
* Override async_internal_added_to_hass
* Adjust tests after rebase
* Apply suggestions from code review
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Address review comments
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-03-30 15:43:04 +02:00
Paulus Schoutsen
929df2bc29
Improve error handling process_play_media_url ( #68322 )
2022-03-20 20:25:15 -07:00
Marc Mueller
be7ef6115c
Make TypeVars private (1) ( #68205 )
2022-03-17 18:52:38 +01:00