Commit Graph

56 Commits (a2730fb29d430a22d3059bf68a6bc13fdb2ccf8b)

Author SHA1 Message Date
Marc Mueller 77f38e33e5
Import names from typing instead of typing_extensions [3.11] (#97065) 2023-07-22 17:03:44 -05:00
J. Nick Koston 457bc4571d
Make RestoreStateData.async_get_instance backwards compatible (#93924) 2023-06-01 19:31:17 +02:00
J. Nick Koston fba826ae9e
Migrate restore_state helper to use registry loading pattern (#93773)
* Migrate restore_state helper to use registry loading pattern

As more entities have started using restore_state over time, it
has become a startup bottleneck as each entity being added is
creating a task to load restore state data that is already loaded
since it is a singleton

We now use the same pattern as the registry helpers

* fix refactoring error -- guess I am tired

* fixes

* fix tests

* fix more

* fix more

* fix zha tests

* fix zha tests

* comments

* fix error

* add missing coverage

* s/DATA_RESTORE_STATE_TASK/DATA_RESTORE_STATE/g
2023-05-30 20:48:17 -05:00
epenet c01b1eb013
Adjust async_track_time_interval name argument (#90838)
Adjust async_track_time_interval naming
2023-04-05 10:58:02 -04:00
J. Nick Koston 02ef7d445d
Allow passing an optional name to async_track_time_interval (#90244)
* Allow passing an optional name to async_track_time_interval

This is the same idea as passing a name to asyncio.create_task which
makes it easier to track down bugs

* more

* short

* still cannot find it

* add a few more

* test
2023-03-25 10:11:14 -04:00
J. Nick Koston 11681f3f31
Pass a helpful name when creating common asyncio tasks in core (#89171) 2023-03-05 12:46:02 +01:00
Marc Mueller 342b406dc0
Add Self typing (1) [mypy 1.0] (#87598) 2023-02-06 22:29:47 -06:00
Franck Nijhof 06a35fb7db
Code styling tweaks to core helpers (#85441) 2023-01-08 13:44:09 -10:00
Erik Montnemery c4afc33fc5
Add abc.ABC to classes with abstract methods (#83546) 2022-12-08 17:50:36 +01:00
Marc Mueller ac858cc2b5
Improve singleton helper typing (#75461)
* Improve singleton helper typing

* Fix type errors
2022-07-21 00:19:02 +02:00
Marc Mueller d09fff595c
Rename existing TypeVars referencing Self type (#75473) 2022-07-20 03:03:22 +02:00
epenet 16900dcef1
Make Store a generic class (#74617) 2022-07-09 22:32:57 +02:00
Marc Mueller bfb1abd3a2
Add type ignore error codes [helpers] (#66776) 2022-02-18 11:31:37 +01:00
Erik Montnemery 009b31941a
Support restoring SensorEntity native_value (#66068) 2022-02-08 14:00:26 -08:00
Marc Mueller 021debb5c5
Resolve implicit imports (#63832) 2022-01-10 17:10:46 +01:00
Marc Mueller 3a32fe9a34
Add strict typing to `core.py` (2) - State (#63240) 2022-01-04 18:33:56 +01:00
Ruslan Sayfutdinov 55f4962c06
Fix pylint plugin which checks relative imports (#62693) 2021-12-23 11:14:47 -08:00
Paulus Schoutsen 8a611eb640
Fix singleton not working with falsey values (#56072) 2021-09-11 12:02:01 -07:00
Richard T. Schaefer 3184f0697f
Add Save Persistent States service (#53881) 2021-08-10 00:38:56 +02:00
J. Nick Koston f96a6e878f
Ensure restore state is not written after the stop event (#49329)
If everything lined up, the states could be written
while Home Assistant is shutting down after the stop
event because the interval tracker was not canceled on
the stop event.
2021-04-17 09:03:18 +02:00
Marc Mueller 6fb2e63e49
Update typing 02 (#48014) 2021-03-17 18:34:19 +01:00
Franck Nijhof 5d5a110a20
None optional hass typing in base entity and notify (#47528) 2021-03-15 15:11:41 +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
Joakim Plate 15db2225da
async_get_instance was not reentrant during await (#38263) 2020-08-12 22:35:24 +02:00
Paulus Schoutsen 5a9970e63c
Dump states in event handler for HA_Stop (#33974)
* Dump states in event handler for HA_Stop

* Fix type
2020-04-13 17:41:01 -07:00
Franck Nijhof 7d3c974747
Use set & dict literals (#33636)
Co-authored-by: Daniel Høyer Iversen <mail@dahoiv.net>
2020-04-04 20:05:15 +02:00
David F. Mulcahey 8b0a0ee521
Don't write storage to disk while stopping (#33456)
* Don't write storage to disk while stopping

* rework change

* lint

* remove delay save and schedule final write at stop

* update tests

* fix test component using private methods

* cleanup

* always listen

* use stop in restore state again

* whitelist JSON exceptions for later

* review comment

* make zwave tests use mock storage
2020-04-02 10:25:28 -07:00
David F. Mulcahey bcd1eb952c
RFC - Add a 3rd state to the HA shutdown sequence for writing… (#33358)
* add third stage to hass shutdown

* use 3rd stage in storage

* update core state

* add writing data to multi stop ignore

* update core test

* review comment

* update name based on feedback
2020-03-30 10:18:39 -07:00
Ville Skyttä 733f1e1101
Helpers typing improvements (#31865) 2020-02-15 13:03:53 -08:00
Paulus Schoutsen e019280d94
Annotate more async functions correctly (#31802) 2020-02-14 10:00:22 -08:00
Paulus Schoutsen e9e44dbd97
Fix callback and async (#31281)
* Fix callback and async

* Fix a return

* Fix test

* Fix mqtt tests

* Fix some more callbacks
2020-01-29 13:59:45 -08:00
Ville Skyttä 5216477353
Be consistent with Home Assistant and Hass.io spelling (#30500)
* Be consistent with Home Assistant spelling

* Be consistent with Hass.io spelling
2020-01-05 14:09:17 +02:00
Paulus Schoutsen 24b25b8917
Restore state helper to work with entity registry restoration (#30451)
* Restore state helper to work with entity registry restoratino

* Update restore_state.py
2020-01-05 11:58:59 +01:00
Bas Nijholt 67c56c860d Sort imports according to PEP8 for 'homeassistant' folder (#29789)
Components are already done
2019-12-09 16:42:10 +01:00
Ville Skyttä 70ddab2f3c
Helpers type hint additions and improvements (#27986)
* Helpers type hint additions and improvements

* Fix async setup dump callback signature
2019-10-21 17:54:59 +03:00
Franck Nijhof 2f0eb07624 Migrate legacy typehints in core to PEP-526 (#26403)
* Migrate legacy typehints in core to PEP-526

* Fix one type
2019-09-03 20:36:04 -07:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Ville Skyttä d64f1e767c Type check all helpers (#25373)
* Type check all helpers, add inline exclusions for work in progress

* Remove unused Script._template_cache

* Add some missing type hints

* Remove unneeded type: ignore

* Type hint fixes

* Mypy assistance tweaks

* Don't look for None in deprecated config "at most once" check

* Avoid None name slugify attempt when generating entity id

* Avoid None state store attempt on entity remove
2019-07-21 09:59:02 -07:00
Paulus Schoutsen cde3f670c2 pylint 2019-07-10 20:47:27 -07:00
Paulus Schoutsen 073327831f
Correctly store removed entities for restore state (#25073)
* Correctly store removed entities for restore state

* Lint

* Do not assume about set encoding
2019-07-10 20:41:03 -07:00
Paulus Schoutsen 06af6f19a3
Entity to handle updates via events (#24733)
* Entity to handle updates via events

* Fix a bug

* Update entity.py
2019-06-26 09:22:51 -07:00
Paulus Schoutsen af3afb673a
Fix restore state crashing invalid entity ID (#20367) 2019-01-23 21:12:38 -08:00
Adam Mills a10cbadb57 Restore states when removing/adding entities (#18890) 2018-12-02 10:51:15 +01:00
Adam Mills 22f27b8621 Store state last seen time separately (#18806)
* Store state last seen time separately

This ensures that infrequently updated entities aren't accidentally
dropped from the restore states store

* Fix mock restore cache
2018-11-30 08:26:19 +01:00
Adam Mills 5c3a4e3d10 Restore states through a JSON store instead of recorder (#17270)
* Restore states through a JSON store

* Accept entity_id directly in restore state helper

* Keep states stored between runs for a limited time

* Remove warning
2018-11-28 13:16:43 +01:00
Otto Winter f5093b474a
Python 3.5 async with (#13283) 2018-03-17 12:27:21 +01:00
Julius Mittenzwei 16cb7388ee Removing asyncio.coroutine syntax from HASS core (#12509)
* changed asyncio.coroutine syntax to new async def/await

* removed py34 from tox environment

* reverted some changes within entity.py

* -

* reverted changes within bootstrap.py

* reverted changes within discovery.py

* switched decorators

* Reverted change within aiohttp_client.py

* reverted change within logging.py

* switched decorators

* Await lock properly

* removed asyncio.coroutine from test
2018-02-25 03:38:46 -08:00
Paulus Schoutsen ca54bbfcc9 RFC: Use bind_hass for helpers (#9745)
* Add Helpers bind_hass functionality

* Update other helpers
2017-10-08 08:17:54 -07:00
Paulus Schoutsen f43db3c615 Replace executor with async_add_job (#7658)
* Remove executor

* Lint

* Lint

* Fix tests
2017-05-26 08:28:07 -07:00
Fabian Affolter a4f1f6e724 Update docstrings (#7374)
* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstring

* Update docstrings

* Update docstrings

* Fix lint issues

* Update docstrings

* Revert changes in dict
2017-05-02 09:18:47 -07:00