Commit graph

451 commits

Author SHA1 Message Date
Allen Porter
84c66b3cad
Add support for services to return data ()
* Add support for service calls with resopnse data.

Update the service calls to allow returning responses with data,
with an initial use case supporting basic service calls usable
within script.

* Revert enttiy platform/component changes

* Remove unnecessary comma diff

* Revert additional unnecessary changes

* Simplify service call

* Simplify and fix typing and revert whitespace

* Clarify typing intent

* Revert more entity service calls

* Revert additional entity service changes

* Set blocking=True for group notify service call

* Revert unnecessary changes

* Reverting more whitespace changes

* Revert more service changes

* Add test coverage for None return case

* Add parameter to service calls indicating return values were requested

* Update tests/test_core.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Add additional service call tests

* Update test comment

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2023-06-16 12:43:35 -04:00
Allen Porter
12129e9d21
Update service call return values and error handling ()
* Update return signature of service calls

* Add timeout error handling in websocket api for service calls

* Update recorder tests to remove assertion on service call

* Remove timeout behavior and update callers that depend on it today

* Fix tests

* Add missing else

* await coro directly

* Fix more tests

* Update the intent task to use wait instead of timeout

* Remove script service call limits and limit constants

* Update tests that depend on service call limits

* Use wait instead of wait_for and add test

* Update homeassistant/helpers/intent.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-16 07:01:40 -07:00
J. Nick Koston
c721cbd10c
Collapse valid state check when creating a state ()
Inline valid state check when creating a state

This was added in  and only used in one place so
it does not need to be another function
2023-05-27 19:53:08 -04:00
J. Nick Koston
e09e4f14d6
Speed up setting state () 2023-05-25 07:34:07 -05:00
J. Nick Koston
780f9bcdc0
Fix shutdown being delayed for cancelling tasks () 2023-05-21 14:17:34 +02:00
J. Nick Koston
32481065a8
Increase size of valid entity id cache () 2023-05-17 13:06:52 +02:00
J. Nick Koston
bf16f6b104
Remove as_compressed_state cache ()
* Remove as_compressed_state cache

All calls to as_compressed_state are now covered by a higher level
JSON cache so there is no need to store these in memory anymore

* Remove as_compressed_state cache

All calls to as_compressed_state are now covered by a higher level
JSON cache so there is no need to store these in memory anymore
2023-05-16 12:39:16 -05:00
J. Nick Koston
99265a983a
Speed up reconnects by caching state serialize () 2023-05-16 02:33:12 -05:00
J. Nick Koston
24284fe379
Speed up validating domains in templates ()
This path gets called quite a bit since most templates
access the state via states.DOMAIN...
2023-05-12 14:57:51 +02:00
J. Nick Koston
07d1a16efd
Add as_dict cache to Context and Event () 2023-04-28 21:15:39 +02:00
J. Nick Koston
237faf62ac
Add a name to the background service call tasks () 2023-04-11 19:23:25 -10:00
epenet
9705607db4
Fix lingering timer in cloud ()
* Fix lingering timer in cloud

* Rename variable

* Improve

* Improve again

* Adjust

* Adjust

* Add property to HassJob instead

* Adjust

* Rename

* Adjust

* Adjust

* Make it read-only

* Add specific test
2023-04-07 11:38:17 +02:00
J. Nick Koston
5eb0c35a97
Add names to common helper tasks () 2023-04-05 08:41:15 +02:00
J. Nick Koston
4c21caa917
Fix filesize doing blocking I/O in the event loop ()
Fix filesize doing I/O in the event loop
2023-03-29 17:26:28 -04:00
Jesse Moody
d7de23fa65
Adjust eventloop -> event loop spelling ()
eventloop -> event loop spelling
2023-03-19 21:53:21 +01:00
J. Nick Koston
5dbab21f9a
Fix missing f-string in filterable_job ()
* Fix missing f-string in filterable_job

* remove bad test
2023-03-08 15:53:48 -05:00
J. Nick Koston
099f16f6b8
Fix missing f-string in async_listen () 2023-03-07 20:19:08 -05:00
Erik Montnemery
aa2267d68e
Rename hass context variable () 2023-03-07 23:21:47 +01:00
J. Nick Koston
11681f3f31
Pass a helpful name when creating common asyncio tasks in core () 2023-03-05 12:46:02 +01:00
J. Nick Koston
8f6cfc25c0
Use ulid-transform for constructing ulids ()
* Use ulid-transform for constructing ulids

A future PR will use the new library to reduce the storage
overhead of ulids in the database

* tweak

* tweak

* bump
2023-02-28 21:09:47 -05:00
J. Nick Koston
b5223e1196
Restore previous behavior of only waiting for new tasks at shutdown ()
* Restore previous behavior of only waiting for new tasks at shutdown

* cleanup

* do a swap instead

* await canceled tasks

* await canceled tasks

* fix

* not needed since we no longer clear

* log it

* reword

* wait for airvisual

* tests
2023-02-26 22:36:18 -05:00
J. Nick Koston
7b61d3763b
Log futures that are blocking shutdown stages () 2023-02-25 12:01:30 +01:00
Erik Montnemery
594b7b7e2c
Add clarifying comment about unit of elevation ()
* Add clarifying comment about unit of elevation

* Make it a docstring
2023-02-22 09:06:43 -05:00
J. Nick Koston
5bc0636905
Replace fire_coroutine_threadsafe with asyncio.run_coroutine_threadsafe ()
fire_coroutine_threadsafe did not hold a reference to the asyncio
task which meant the task had the risk of being prematurely
garbage collected
2023-02-21 21:16:18 -05:00
modrisb
9fd35d53e7
Change core return code processing ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-17 20:56:02 -05:00
Paulus Schoutsen
3a32d2bdcb
Add background tasks to config entries ()
* Use a set for config entries task tracking

* Allow adding background tasks to config entries

* Add tests for config entry add tasks

* Update docstrings on core create task

* Migrate roon and august

* Use in more places

* Guard for None
2023-02-17 13:50:05 -05:00
Paulus Schoutsen
6cab27f378
Add support for background tasks in HA ()
* Add support for background tasks

* make name mandatory for background tasks

* Update docstring

* async_create_background_task

* Grammar
2023-02-16 20:39:29 -05:00
Paulus Schoutsen
d54f59478f
Keep task references while running ()
* Keep task references while running

* Update pilight tests pointing at correct logger call

* Fix graphite tests

* Fix profiler tests

* More graphite test fixes

* Remove extra sleep

* Fix tests

* Shutdown background tasks as part of stage 1

* Remove unnecessary sleep in test

* Remove unused method on mock hass

* Skip on cancelled too

* Remove background tasks

* Test trigger variables without actually sleeping

* Fix graphite

* One more graphite grrrrrrr
2023-02-13 23:16:59 -05:00
J. Nick Koston
e41af8928b
Restore original aiohttp cancelation behavior () 2023-02-13 22:00:36 -06:00
Marc Mueller
342b406dc0
Add Self typing (1) [mypy 1.0] () 2023-02-06 22:29:47 -06:00
Franck Nijhof
ca1a12898c
Enable Ruff D212 () 2023-02-03 23:08:48 +01:00
J. Nick Koston
c612a92cfb
Use python defaults for comparing State, LazyState, and Event objects ()
* Speed up comparing State and Event objects

Use default python implementation for State and Event __hash__ and __eq__

The default implementation compared based on the id() of the object
which is effectively what we want here anyways. These overrides are
left over from the days when these used to be attrs objects

By avoiding implementing these ourselves all of the equality checks
can happen in native code

* tweak

* adjust tests

* write out some more

* fix test to not compare objects

* more test fixes

* more test fixes

* correct stats tests

* fix more tests

* fix more tests

* update sensor recorder tests
2023-01-29 13:31:43 -05:00
Marc Mueller
6397138589
Update Optional typing (1) [Py310] ()
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-01-23 09:56:10 +01:00
Marc Mueller
45b4b0e990
Import ParamSpec from typing [Py310] ()
* Import ParamSpec from typing [Py310]

* Update additional imports
2023-01-23 07:28:43 +01:00
Franck Nijhof
79b52a2b41
Stricter pylint message control () 2023-01-20 13:47:55 +01:00
Franck Nijhof
64c2340fab
Core code styling improvements () 2023-01-15 23:00:51 +01:00
J. Nick Koston
57239769ba
Only build compressed states once () 2023-01-09 12:07:32 -10:00
Franck Nijhof
b0cee0bc46
String formatting and max line length - Part 1 ()
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-12-22 10:12:50 +01:00
Marc Mueller
490aec0b11
Update pylint to 2.15.7 () 2022-11-30 12:20:18 +01:00
puddly
8c8994352d
Allow only specific packages to be skipped during startup dependency installation () 2022-11-30 08:38:52 +01:00
Erik Montnemery
67e4f2c202
Raise repairs issue if country is not configured () 2022-11-28 09:54:13 +01:00
Erik Montnemery
e1338adf1a
Allow configuring country and language in core config ()
* Allow configuring country and language in core config

* Add script for updating list of countries

* Use black for formatting

* Fix quoting

* Move country codes to a separate file

* Address review comments

* Add generated/countries.py

* Get default language from owner account

* Remove unused variable

* Add script to generate list of supported languages

* Add tests

* Fix stale docsring

* Use format_python_namespace

* Correct async_user_store

* Improve typing

* Fix with_store decorator

* Initialize language in core store migration

* Fix startup

* Tweak

* Apply suggestions from code review

Co-authored-by: Franck Nijhof <git@frenck.dev>

* Update storage.py

Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-11-24 23:25:50 +01:00
epenet
67d1dde69f
Rename IMPERIAL_SYSTEM to US_CUSTOMARY_SYSTEM ()
* 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
a26b3e7a34
Refactor access to ConfigStore ()
* Refactore access to ConfigStore

* Make tests async

* Reset config during test
2022-10-17 13:59:04 +02:00
epenet
bbb0b2a0e1
Refactor the core config store ()
* Add helper for config Store

* Use internal class
2022-10-17 10:13:53 +02:00
epenet
bff5d1123f
Deprecate CONF_UNIT_SYSTEM_*** constants ()
* 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
4dd0c079d5
Deprecate name property of unit system () 2022-10-14 12:06:14 +02:00
Marc Mueller
3a9ecab98a
Improve iterable typing (1) () 2022-10-01 00:12:39 +02:00
Erik Montnemery
61ff1b786b
Add a context variable holding a HomeAssistant reference ()
* Add a context variable holding a HomeAssistant reference

* Move variable setup and update test

* Refactor

* Revert "Refactor"

This reverts commit 346d005ee6.

* Set context variable when creating HomeAssistant object

* Update docstring

* Update docstring

Co-authored-by: jbouwh <jan@jbsoft.nl>
2022-08-22 15:58:01 +02:00
Marc Mueller
dc47121f2c
Better type hass_job method calls () 2022-08-09 16:12:33 -04:00