Commit Graph

2131 Commits (a2730fb29d430a22d3059bf68a6bc13fdb2ccf8b)

Author SHA1 Message Date
Franck Nijhof 296c27859e
Fix issue registry sending unneeded update events (#98230) 2023-08-10 21:57:42 -04:00
G Johansson aacb8aecfc
Refactor Rest Sensor with ManualTriggerEntity (#97396)
* ManualTriggerEntity for rest sensor

* add availability test

* review comments

* last fixes
2023-08-10 21:46:56 +02:00
Franck Nijhof 868a5f377f
Ruff: isort don't split imports based on trailing comma (#98162) 2023-08-10 14:27:03 +02:00
G Johansson 4531dbbe62
Refactor Rest Binary sensor with ManualTriggerEntity (#97400)
* Refactor Rest Binary sensor w/ ManualTriggerEntity

* test availability

* review comments

* Use super

* Fix config
2023-08-10 12:59:23 +02:00
Erik Montnemery e1f0b44ba4
Use math.isfinite instead of explicitly checking for both nan and inf (#98103) 2023-08-09 14:13:57 +02:00
Erik Montnemery 683c2f8d22
Add service for getting a weather forecast (#97078)
* Add service for getting a weather forecast

* Fix translations

* Improve service description

* Improve error handling

* Adjust typing

* Adjust typing

* Adjust service response format
2023-08-07 14:05:37 +02:00
Paul Bottein 83af2f5b8b
Allow to sort options in select selector (#97680)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-08-03 21:49:22 +02:00
Franck Nijhof af5fc7e759
Ensure load the device registry if it contains invalid configuration URLs (#97589) 2023-08-01 23:15:31 +02:00
J. Nick Koston 094f2cbad7
Fix saving subclassed datetime objects in storage (#97502) 2023-07-31 18:49:02 +02:00
Marc Mueller 4d9b73033d
Update python-typing-update to 0.6.0 (#97531) 2023-07-31 17:59:40 +02:00
G Johansson 1f11ce63fc
Manual trigger entity fix name influence entity_id (#97398) 2023-07-30 18:47:34 +02:00
J. Nick Koston 13349e76ed
Avoid firing update coordinator callbacks when nothing has changed (#97268) 2023-07-28 12:19:20 -05:00
Franck Nijhof 737ac8c600
Fix DeviceInfo configuration_url validation (#97319) 2023-07-27 18:57:01 +02:00
Paulus Schoutsen aad281db18
Add service to OpenAI to Generate an image (#97018)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-07-26 10:14:18 +02:00
Franck Nijhof b655b9d530
Allow for translating service examples (#97141) 2023-07-24 15:57:02 +02:00
Marc Mueller 995c29e052
Cleanup EventType typing (#97136) 2023-07-24 13:18:38 +02:00
Marc Mueller 582499a260
Improve `async_track_template_result` callback typing (#97135) 2023-07-24 12:42:17 +02:00
Marc Mueller c0da6b822e
Fix ruff (#97131) 2023-07-24 10:34:16 +02:00
Marc Mueller 3371c41bda
Improve `async_track_device_registry_updated_event` callback typing (#97125) 2023-07-24 09:42:01 +02:00
Marc Mueller 0624345322
Improve `async_track_entity_registry_updated_event` callback typing (#97124) 2023-07-24 09:14:10 +02:00
Marc Mueller 235b98da8a
Use EventType for remaining event helper methods (#97121) 2023-07-23 18:32:29 -05:00
Marc Mueller 69d7b035e0
Use EventType for more helper methods (#97107) 2023-07-23 23:22:04 +02:00
Franck Nijhof 30058297cf
Migrate backported StrEnum to built-in StrEnum (#97101) 2023-07-23 23:19:24 +02:00
Marc Mueller bdd253328d
Add generic Event class (#97071) 2023-07-23 21:51:54 +02:00
J. Nick Koston e60313628f
Add a cancel message to the aiohttp compatiblity layer (#97058) 2023-07-22 17:06:32 -05:00
Marc Mueller 77f38e33e5
Import names from typing instead of typing_extensions [3.11] (#97065) 2023-07-22 17:03:44 -05:00
Jan Bouwhuis 9424d11408
Allow homeassistant in MQTT configuration_url schema (#96107) 2023-07-22 22:50:58 +02:00
Joost Lekkerkerker 0ba2531ca4
Fix bug in check_config when an integration is removed by its own validator (#96068)
* Raise if present is False

* Fix feedback

* Update homeassistant/helpers/check_config.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/helpers/check_config.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix tests

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-07-20 11:45:44 +02:00
G Johansson 4e2b00a443
Refactor SQL with ManualTriggerEntity (#95116)
* First go

* Finalize sensor

* Add tests

* Remove not need _attr_name

* device_class

* _process_manual_data allow Any as value
2023-07-20 11:35:08 +02:00
Erik Montnemery f0953dde95
Add comment to EntityPlatform._async_add_entity about update_before_add (#96891) 2023-07-19 13:07:23 +02:00
J. Nick Koston 01e66d6fb2
Improve handling of unrecoverable storage corruption (#96712)
* Improve handling of unrecoverable storage corruption

fixes #96574

If something in storage gets corrupted core can boot loop
or if its integration specific, the integration will fail to
start.

We now complainly loudly in the log, move away the corrupt data
and start fresh to allow startup to proceed so the user can
get to the UI and restore from backup without having to attach
a console (or otherwise login to the OS and manually modify files).

* test for corruption

* ensure OSError is still fatal

* one more case

* create an issue for corrupt storage

* fix key

* persist

* feedback

* feedback

* better to give the full path

* tweaks

* grammar

* add time

* feedback

* adjust

* try to get issue_domain from storage key

* coverage

* tweak wording some more
2023-07-19 09:23:12 +02:00
Paul Bottein d8c989f732
Make default theme selectable for set theme service (#96849) 2023-07-18 17:36:35 +02:00
Franck Nijhof b9f92b526b
Add prefix support to text selector (#96830) 2023-07-18 12:17:31 +02:00
J. Nick Koston bc6a41fb94
Remove deprecated state.get_changed_since (#96579) 2023-07-18 09:42:48 +02:00
Marc Mueller 9e67bccb89
Replace EventType annotations with Event (#96426) 2023-07-18 08:51:06 +02:00
J. Nick Koston 3a06659120
Speed up single entity/response service calls (#96729)
* Significantly speed up single entity/response service calls

Since the majority of service calls are single entity, we can
avoid creating tasks in this case. Since the multi-entity
service calls always check the result and raise, we can switch
the asyncio.wait to asyncio.gather

* Significantly speed up single entity/response service calls

Since the majority of service calls are single entity, we can
avoid creating tasks in this case. Since the multi-entity
service calls always check the result and raise, we can switch
the asyncio.wait to asyncio.gather

* revert

* cannot be inside pytest.raises

* one more

* Update homeassistant/helpers/service.py
2023-07-17 09:33:13 +02:00
J. Nick Koston 7ec506907c
Ensure async_get_system_info does not fail if supervisor is unavailable (#96492)
* Ensure async_get_system_info does not fail if supervisor is unavailable

fixes #96470

* fix i/o in the event loop

* fix tests

* handle some more failure cases

* more I/O here

* coverage

* coverage

* Update homeassistant/helpers/system_info.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* remove supervisor detection fallback

* Update tests/helpers/test_system_info.py

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-07-16 11:10:07 -04:00
Erik Montnemery 614f3c6a15
Move device info validation to device registry (#96465)
* Move device info validation to device registry

* Don't move DeviceInfo

* Fix type annotation

* Don't block adding device for unknown config entry

* Fix test

* Remove use of locals()

* Improve error message
2023-07-14 08:55:17 -04:00
Erik Montnemery 7539cf25be
Don't require passing identifiers to DeviceRegistry.async_get_device (#96479)
* Require keyword arguments to DeviceRegistry.async_get_device

* Update tests

* Update tests

* Don't enforce keyword arguments
2023-07-13 13:39:25 -04:00
J. Nick Koston 08af42b00e
Fix mixed case service schema registration (#96448) 2023-07-12 14:39:51 -10:00
Paul Bottein e513b7d0eb
Add condition selector for blueprint (#96350)
* Add condition selector for blueprint

* Add tests and validation

* Update comment
2023-07-12 10:58:35 -04:00
Franck Nijhof 594d240a96
Migrate & fix logger services to support translations (#96393)
* Migrate logger services to support translations

* Fix tests and schema validation

* Apply suggestions from code review

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
2023-07-12 10:37:18 -04:00
Franck Nijhof f25d5a157a
Fix service schema to allow for services without any fields/properties (#96346) 2023-07-11 19:33:07 +02:00
Franck Nijhof f054de0ad5
Add support for service translations (#95984) 2023-07-11 15:52:12 +02:00
Erik Montnemery f46188c85a
Improve the docstring of some config schema generators (#96296) 2023-07-11 11:34:16 +02:00
Paulus Schoutsen eee8566694
Differentiate between device info types (#95641)
* Differentiate between device info types

* Update allowed fields

* Update homeassistant/helpers/entity_platform.py

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

* Split up message in 2 lines

* Use dict for device info types

* Extract device info function and test error checking

* Simplify parsing device info

* move checks around

* Simplify more

* Move error checking around

* Fix order

* fallback config entry title to domain

* Remove fallback for name to config entry domain

* Ensure mocked configuration URLs are strings

* one more test case

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-07-10 09:56:06 -04:00
J. Nick Koston 039a3bb6e9
Only load the device entry when it changes in the base entity (#95801) 2023-07-10 15:17:35 +02:00
Erik Montnemery 3d064b7d6b
Add filters to cover/services.yaml (#95854) 2023-07-08 11:51:02 +02:00
Jan Bouwhuis 18ee9f4725
Refactor async_get_hass to rely on threading.local instead of a ContextVar (#96005)
* Test for async_get_hass

* Add Fix
2023-07-07 14:52:38 -04:00
Erik Montnemery 86a397720f
Move platform_integration_no_support issue to the homeassistant integration (#95927)
* Move platform_integration_no_support issue to the homeassistant integration

* Update test

* Improve repair text

* Update test
2023-07-07 13:31:54 +02:00
J. Nick Koston b7b8afffd0
Handle integrations with empty services or failing to load during service description enumeration (#95911)
* wip

* tweaks

* tweaks

* add coverage

* complain loudly as we never execpt this to happen

* ensure not None

* comment it
2023-07-06 11:19:06 -04:00
Jan Bouwhuis b9c7e7c15e
Fix not including device_name in friendly name if it is None (#95485)
* Omit device_name in friendly name if it is None

* Fix test
2023-07-06 11:14:09 -04:00
Bram Kragten 342d07cb92
Set correct `response` value in service description when `async_set_service_schema` is used (#95985)
* Mark scripts as response optional, make it always return a response if return_response is set

* Update test_init.py

* Revert "Update test_init.py"

This reverts commit 8e113e54db.

* Split + add test
2023-07-06 10:24:34 -04:00
J. Nick Koston 1dfa2f3c6b
Use slots in TraceElement (#95877) 2023-07-05 08:44:00 +02:00
J. Nick Koston 4d3662d4da
Tune httpx keep alives for polling integrations (#95782)
* Tune keep alives for polling integrations

aiohttp closes the connection after 15s by default,
and httpx closes the connection after 5s by default.

We have a lot of integrations that poll every 10-60s
which create and tear down connections over and over.

Set the keep alive time to 65s to maximize connection
reuse and avoid tls negotiation overhead

* Apply suggestions from code review

* adjust
2023-07-03 14:21:59 -04:00
Paulus Schoutsen e4f617e92e
Update log message when referenced entity not found (#95577)
* Update log message when referenced entity not found

* Update homeassistant/helpers/service.py

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

* Update test

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-07-02 00:04:03 +02:00
Paulus Schoutsen 9280dc69ae
Default device name to config entry title (#95547)
* Default device name to config entry title

* Only apply name default if device info provided

* Fix logic detecting type of device info
2023-06-30 13:54:20 -04:00
Bram Kragten a7dfe46fb1
Add conversation agent selector, use in `conversation.process` service (#95462) 2023-06-28 21:38:06 -04:00
Erik Montnemery e18f7dffb0
Teach validate_config to validate lists of conditions (#95380)
* Teach validate_config to validate lists of conditions

* Update test
2023-06-27 19:44:23 +02:00
Paulus Schoutsen 243abf32c0
Add test to stop action (#95376) 2023-06-27 19:38:30 +02:00
Franck Nijhof 3e85a29b86
Move overlapping pylint rules to ruff, disable mypy overlap (#94359) 2023-06-27 17:42:46 +02:00
Erik Montnemery cb22fb16f8
Allow returning a script variable from a script (#95346)
* Allow returning a script variable from a script

* Don't allow returning a template result

* Raise if response variable is undefined

* Add test

* Update homeassistant/helpers/script.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Format code

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-06-27 17:13:53 +02:00
Erik Montnemery 071d3a474f
Base entity ids on English for languages not using Latin script (#91357) 2023-06-27 14:37:50 +02:00
Paulus Schoutsen 5f14cdf69d
Allow stopping a script with a response value (#95284) 2023-06-27 08:24:22 +02:00
J. Nick Koston c4288e7b1f
Use cached_property in entity.py instead of manual cache (#95307) 2023-06-26 19:18:46 -05:00
Paulus Schoutsen d95c241a1a
Add service response values to service descriptions (#95262) 2023-06-26 12:57:43 -04:00
Erik Montnemery 8e2ba81995
Add image platform to the template integration (#94928)
* Add image platform to the template integration

* Set a default name

* Fix typo

* Add tests

* Improve test coverage

* Derive content-type from fetched image
2023-06-26 15:54:51 +02:00
Erik Montnemery 8fda56d2c9
Stable entity registry id when a deleted entity is restored (#77710)
* Stable entity_id and registry id when a deleted entity is restored

* Don't restore area_id

* Don't restore entity_id

* Address review comments
2023-06-26 15:54:35 +02:00
Allen Porter 1d9821efa2
Fix spelling mistake in script.py (#95210)
Update script.py
2023-06-25 21:00:50 -04:00
J. Nick Koston 9051750add
Cache entity translation lookups and keys (#95180) 2023-06-25 08:50:48 -05:00
Allen Porter 528c206094
Add script specific error messages for `response_variable` (#95188) 2023-06-24 21:34:57 -07:00
J. Nick Koston 9354df975c
Reduce overhead to set up and write entity state (#95162) 2023-06-24 14:16:28 -05:00
Allen Porter b9b5fe6be8
Add service response data for listing calendar events (#94759)
* Add service response data for listing calendar events

Add the capability of response data for for the entity component.

* Rename input arguments and add service description

* Improve list events to be more user friendly

Allow the end date to be determined based on a relative time duration. Make the start time optional and set to "now". Add additional test coverage. Update demo calendar to actually perform date range checks.

* Wrap docstrings properly.

* Increase test coverage

* Update to use new API calls

* Readability improvements

* Wrap docstrings

* Require at least one of end or duration

* Check for multiple entity matches earlier in the request

* Update documentation strings
2023-06-23 23:34:34 -04:00
Marc Mueller 6033f39a0d
Partial revert "Add TypeVar defaults for DataUpdateCoordinator (#95026)" (#95101)
* Revert "Add TypeVar defaults for DataUpdateCoordinator and EntityComponent (#95026)"

This reverts commit 90f5b1c323.

* Don't revert everything
2023-06-23 14:42:34 +02:00
Franck Nijhof e2f5a707ce
Fix use_device_name in case device device class translations are used (#95010)
Co-authored-by: Erik <erik@montnemery.com>
2023-06-22 11:30:19 +02:00
Marc Mueller 90f5b1c323
Add TypeVar defaults for DataUpdateCoordinator and EntityComponent (#95026) 2023-06-22 03:33:23 +02:00
J. Nick Koston 8d2daaa694
Limit cache size of EntityValues (#94983) 2023-06-21 22:23:35 +02:00
Marc Mueller 86792fcc2f
Update mypy to 1.4.0 (#94987) 2023-06-21 16:12:51 +02:00
J. Nick Koston f8bef95eb6
Reduce code in entity filter (#94882) 2023-06-21 08:37:19 +01:00
Erik Montnemery d2d6389742
Improve storage helper typing (#94929) 2023-06-20 22:50:10 +02:00
Allen Porter 30e8f806c1
Improve service response data APIs (#94819)
* Improve service response data APIs

Make the API naming more consistent, and require registration that a
service supports response data so that we can better integrate with
the UI and avoid user confusion with better error messages.

* Improve test coverage

* Add an enum for registering response values

* Assign enum values

* Convert SupportsResponse to StrEnum

* Update service call test docstrings

* Add tiny missing full stop in comment

---------

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2023-06-20 06:24:31 -07:00
Erik Montnemery 4a8adae146
Teach alarm_control_panel device trigger about entity registry ids (#60977)
* Teach alarm_control_panel device trigger about entity registry ids

* Lint code

* Address review comment
2023-06-20 08:27:31 -04:00
Erik Montnemery 609a573b55
Regenerate instance ID on error (#94898) 2023-06-20 11:16:51 +02:00
Allen Porter c4284c07b6
Allow scripts to capture service response data in variables (#94757)
* Allow scripts service actions to save return values

* Simplify script service response data

* Rename result_variable to response_variable based on feedback
2023-06-16 22:59:44 -04:00
J. Nick Koston 68cf796be8
Speed up entity service calls (#94731)
* Speed up entity service calls

- Avoid permissions check if the caller is an admin
- Use set intersection instead of linear search of entity platforms to find entities

* tweak

* fix light test to not use an admin user
2023-06-16 21:07:57 -04:00
Allen Porter 12129e9d21
Update service call return values and error handling (#94657)
* 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
Erik Montnemery 950b25bf42
Remove unnecessary assert from Entity (#94711) 2023-06-16 14:07:25 +02:00
J. Nick Koston 26be0fab78
Fix debouncer not scheduling timer when wrapped function raises (#94689)
* Fix debouncer not scheduling timer when callback function raises

* test coro as well

* preen
2023-06-15 22:15:49 -04:00
Erik Montnemery 334dacc322
Change Entity.name default to UNDEFINED (#94574)
* Change Entity.name default to UNDEFINED

* Update typing

* Update Pylint plugin

* Update TTS test
2023-06-15 11:09:53 +02:00
J. Nick Koston a0c023d5cb
Reduce overhead to lookup items in the entity and device registry (#94568) 2023-06-14 20:47:18 +02:00
Erik Montnemery 2406b235b4
Name unnamed binary sensors by their device class (#92940)
* Name unnamed binary sensors by their device class

* Update type annotations

* Fix loading of entity component translations

* Add test

* Update integrations

* Set abode and rfxtrx binary_sensor name to None

* Revert changes in homekit_controller
2023-06-13 19:48:54 +02:00
Erik Montnemery 771a73c034
Add missing callback decorator to event helpers (#94483) 2023-06-13 11:16:43 +02:00
Raman Gupta aab58ad89c
Fix entity and device selector TypedDict's (#94510) 2023-06-13 10:52:55 +02:00
Erik Montnemery 59f5b8f2d6
Remove unneeded checks for Entity.platform (#94321)
* Remove unneeded checks for Entity.platform

* Update tests

* Prevent breaking integrations without an EntityComponent

* Warn when entity has no platform
2023-06-09 15:17:41 +02:00
Erik Montnemery 4085c4f6d8
Tweak typing of Entity.platform (#88321)
* Tweak typing of Entity.platform

* Fix mypy errors

* Fix update test

* Improve comments
2023-06-09 10:56:04 +02:00
Franck Nijhof 6db1fbf480
Fix repair issue about no yaml for config entries (#94271) 2023-06-08 18:22:34 +02:00
Michael Benz 305fa128fb
Add reload support to intent_script (#93404)
* support live reload of intent_script

* add services.yaml

* update tesls for full code coverage

* Update based on feedback

* fix intent_script reload when no intent_script config

* Update homeassistant/helpers/intent.py

* update tests to handle no_existing better

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2023-06-03 14:02:23 -04:00
J. Nick Koston 457bc4571d
Make RestoreStateData.async_get_instance backwards compatible (#93924) 2023-06-01 19:31:17 +02:00
Erik Montnemery f9037d5f6d
Add platform only config schema to nsw_fuel_station and ping (#93913) 2023-06-01 17:30:15 +02:00
Erik Montnemery c1c319d4d1
Rename `cv.no_yaml_config_schema` to `cv.config_entry_only_config_schema` (#93908)
* Rename cv.no_yaml_config_schema to cv.config_entry_only_config_schema

* ✏️
2023-06-01 13:15:48 +02:00