Commit Graph

2131 Commits (a2730fb29d430a22d3059bf68a6bc13fdb2ccf8b)

Author SHA1 Message Date
J. Nick Koston aff7345ea0
Improve event filters to reject earlier (#89337)
* Improve event filters to reject earlier

- Avoid running the callbacks for state added/removed from
  a domain if there are no listeners that care about the domain

- Remove some impossible checks in the listeners that will
  never match since they were already rejected by the filter

* leave one guard since there is a race when we return control via await
2023-03-08 10:25:42 -05: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
Paul Bottein e95944bf9f
Add filter options to entity and device selectors (#87536)
* Add support for multiple device classes

* Add support for entity filter selector

* Add support for device filter selector

* Apply suggestions

* Fix wrong property name

* Update snapshot

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-02-27 10:38:18 -05:00
J. Nick Koston bea81d3f63
Fix lock services not removing entity fields (#88805) 2023-02-26 18:59:28 -05:00
J. Nick Koston 57360a7528
Prevent new discovery flows from being created when stopping (#88743) 2023-02-25 12:02:07 +01:00
J. Nick Koston f52a5f6965
Make hass.async_stop an untracked task (#88738) 2023-02-24 23:11:48 -05:00
J. Nick Koston 0223058d25
Reduce overhead to save json data to postgresql (#88717)
* Reduce overhead to strip nulls from json

* Reduce overhead to strip nulls from json

* small cleanup
2023-02-24 21:37:36 -05:00
Erik Montnemery d90ee85118
Allow conditions to be implemented in platforms (#88509)
* Allow conditions to be implemented in platforms

* Update tests

* Tweak typing

* Rebase fixes
2023-02-23 22:30:51 -05:00
David Poll af49b98475
Enable jinja loop controls (break/continue) (#88625)
Enables jinja loop controls (break/continue)
2023-02-23 22:14:28 -05:00
Erik Montnemery 1f34fa63ab
Always include platform in `config/entity_registry/list_for_display` (#88601)
Always include platform in config/entity_registry/list_for_display
2023-02-22 17:59:52 +01:00
Erik Montnemery 6d9411b8a1
Improve trigger platform typing (#88511)
* Improve trigger platform typing

* Tweak docstring

* Revert "Tweak docstring"

This reverts commit c31f790fc3.

* Tweak docstring
2023-02-22 11:59:53 +01:00
J. Nick Koston 8806c3dd20
Speed up loading non-english language translations (#88553)
Speed up loading non-english languages

We called async_get_integrations in each gathered task
instead of once for both languages we were loading
2023-02-21 21:18:33 -05:00
Erik Montnemery 0c4c95394e
Add WS command config/entity_registry/list_for_display (#87787)
* Add WS command config/entity_registry/list_for_display

* Make more keys in the display dict optional

* Move disabled_by check to ws command handler

* Hide hidden_by if not hidden

* Use send_json_auto_id in the new test

* Don't include entities which have no data needed for display

* Include platform for entries with translation_key
2023-02-21 20:40:39 +01:00
Erik Montnemery 30ebc6604f
Invert trigger._PLATFORM_ALIASES (#88503) 2023-02-20 22:14:41 +01:00
Erik Montnemery cc4a179ca8
Support templating for in state conditions (#88411) 2023-02-20 18:57:00 +01:00
Erik Montnemery 83e5bf7ae8
Use entity_sources to determine integration in recorder platforms (#88382) 2023-02-18 07:21:41 -06:00
Michael Hansen dc30210237
Use blocking in intent service calls and verify results (#88035)
* Use blocking in service calls and verify result

* Block for 2 seconds and update states after

* Small timeout in service call to allow exceptions

* Move sun test
2023-02-16 14:01:41 -05:00
epenet ba23816a0c
Inverse json import logic (#88099)
* Fix helpers and util

* Adjust components

* Move back errors

* Add report

* mypy

* mypy

* Assert deprecation messages

* Move test_json_loads_object

* Adjust tests

* Fix rebase

* Adjust pylint plugin

* Fix plugin

* Adjust references

* Adjust backup tests
2023-02-16 11:37:57 +01:00
J. Nick Koston c0e22be7a8
Fix allowing identical flows to be created before startup (#88213)
The check for identical flows only worked after
the start event. We now check against pending
flows as well

If startup took a while we could end up
with quite the thundering herd
2023-02-15 21:36:00 -05:00
Franck Nijhof 9030ca05b1
Enable Ruff SIM118 (#87772) 2023-02-15 12:39:12 +01:00
epenet a1b7842df2
Fix incorrect reference to json WriteError (#88161) 2023-02-15 10:40:26 +01:00
J. Nick Koston e41af8928b
Restore original aiohttp cancelation behavior (#88046) 2023-02-13 22:00:36 -06:00
J. Nick Koston ac97097167
Speed up template lru_caches (#87942)
By avoiding the argument unpacking these functions are faster
and reduce stack overhead
2023-02-12 14:13:13 -05:00
J. Nick Koston e19f8595fa
Small cleanups to template helper (#87944)
- reduce dict lookups
- avoid split_entity_id
2023-02-12 14:11:48 -05:00
J. Nick Koston aa8927c98c
Speed up loops with jinja templates (#87945) 2023-02-12 18:40:55 +01:00
Michael Hansen 8cd5106c15
Add HassGetState intent for queries (#87808)
* Use names instead of entity ids for list

* Add HassGetState for Assist queries

* Add unknown area to test

* Clean up and test device classes
2023-02-09 23:39:46 -05:00
Erik Montnemery cc564026fa
Move EntityCategory to homeassistant.const (#87792)
* Move EntityCategory to homeassistant.const

* Fix more imports
2023-02-09 20:15:37 +01:00
Erik Montnemery 8ccb3b7151
Fix circular import loop in homeassistant/helpers/entity.py (#87780)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-09 19:15:53 +01:00
Erik Montnemery 2d2ff19949
Round value in state_with_unit template function (#87619) 2023-02-09 12:54:59 +01:00
Erik Montnemery 93dafefd96
Include entity options in RegistryEntry.as_partial_dict (#87539) 2023-02-08 08:32:46 -05:00
epenet a202588fd2
Add return type to json_loads (#85672)
* Add JSON type definitions

* Sample use

* Keep mutable for a follo-up PR (avoid dead code)

* Use list/dict

* Remove JsonObjectType

* Remove reference to Union

* Cleanup

* Improve rest

* Rename json_dict => json_data

* Add docstring

* Add type hint to json_loads

* Add cast

* Move type alias to json helpers

* Cleanup

* Create and use json_loads_object

* Make error more explicit and add tests

* Use JsonObjectType in conversation

* Remove quotes
2023-02-07 17:21:55 +01:00
Marc Mueller 42008c50f3
Enable error-code `truthy-iterable` [mypy 1.0] (#87596) 2023-02-07 11:16:22 +01:00
Marc Mueller ea4e2ab4aa
Add Self typing (4) [mypy 1.0] (#87601) 2023-02-06 22:30:22 -06:00
Marc Mueller 342b406dc0
Add Self typing (1) [mypy 1.0] (#87598) 2023-02-06 22:29:47 -06:00
Paulus Schoutsen a090652560
Use correct state in Entity repr and output similar value to State class (#87519)
* Use correct state in Entity repr

* Test Entity.__repr__

* Align with State class
2023-02-06 13:35:36 -05:00
krahabb 899342d391
Refactor async_call_later to improve performance and reduce conversion loss (#87117)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-05 12:04:38 -06:00
Franck Nijhof fcb612cd6f
Collection of code styling tweaks (#87344) 2023-02-03 23:51:27 +01:00
Erik Montnemery 4d4fb2477d
Optionally update sensor units when unit system is changed (#83851) 2023-02-03 16:30:50 +01:00
epenet 810367b757
Fix `can not` typo (#87254) 2023-02-03 11:37:16 +01:00
Franck Nijhof b8a1f87073
Fix schema typing on async_register_entity_service (#87250) 2023-02-03 11:25:02 +01:00
Karlie Meads e40a9822f5
Fix disabled condition within an automation action (#87213)
fixes undefined
2023-02-02 22:35:02 +01:00
Franck Nijhof 5e81d28116
Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +01:00
Marc Mueller 07a3046d11
Update pylint to 2.16.0 (#87083) 2023-02-02 12:49:01 +01:00
Michael Hansen be69c81db5
Prioritize entity names over area names in Assist matching (#86982)
* Refactor async_match_states

* Check entity name after state, before aliases

* Give entity name matches priority over area names

* Don't force result to have area

* Add area alias in tests

* Move name/area list creation back

* Clean up PR

* More clean up
2023-01-30 23:46:25 -05:00
Michael Hansen adeaf746ec
Use device area id in intent matching (#86678)
* Use device area id when matching

* Normalize whitespace in response

* Add extra test entity
2023-01-26 09:48:49 -06:00
Erik Montnemery fea30c1ce9
Terminate strings at NUL when recording states and events (#86687) 2023-01-26 11:11:03 +01:00
Paulus Schoutsen df0fc30695
Fix oauth2 error (#86634) 2023-01-25 20:50:16 +01:00
Vaarlion 3007e0259d
Add a `contains` jinja filter and test (#86390) 2023-01-25 11:51:47 +01:00
Michael Hansen ea95abcb30
Use intent responses from home-assistant-intents (#86484)
* Use intent responses from home_assistant_intents

* Use error responses from home_assistant_intents

* Remove speech checks for intent tests (set by conversation now)

* Bump hassil and home-assistant-intents versions

* Use Home Assistant JSON reader when loading intents

* Remove speech checks for light tests (done in agent)

* Add more tests for code coverage

* Add test for reloading on new component

* Add test for non-default response
2023-01-23 22:38:41 -05:00
Marc Mueller 6f94e47270
Update Union typing (6) [Py310] (#86454) 2023-01-23 15:01:07 +01:00
Marc Mueller 4f87c1f30f
Update pre-commit-config [Py310] (#86415) 2023-01-23 09:59:44 +01:00
Marc Mueller 6397138589
Update Optional typing (1) [Py310] (#86417)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-01-23 09:56:10 +01:00
Marc Mueller da35097803
Update Optional typing (2) [Py310] (#86419) 2023-01-23 09:10:05 +01:00
Marc Mueller 8abce25948
Update Union typing (4) [Py310] (#86427) 2023-01-23 09:04:40 +01:00
Marc Mueller 45b4b0e990
Import `ParamSpec` from typing [Py310] (#86413)
* Import ParamSpec from typing [Py310]

* Update additional imports
2023-01-23 07:28:43 +01:00
J. Nick Koston ca4d7634a8
Switch an `asyncio.wait_for` in the template helper to `async_timeout` (#86349)
Switch an asyncio.wait_for in the template helper to async_timeout

Eliminates the extra task when calling async_render_will_timeout
2023-01-22 00:02:03 +02:00
Franck Nijhof 79b52a2b41
Stricter pylint message control (#86154) 2023-01-20 13:47:55 +01:00
Aarni Koskela 656632f504
Fix docstring in helpers.template_entity (#86227) 2023-01-19 21:24:44 -05:00
Michael Hansen 5aca996f22
HassTurnOn/Off intents to also handle cover entities (#86206)
* Move entity/area resolution to async_match_states

* Special case for covers in HassTurnOn/Off

* Enable light color/brightness on areas

* Remove async_register from default agent

* Remove CONFIG_SCHEMA from conversation component

* Fix intent tests

* Fix light test

* Move entity/area resolution to async_match_states

* Special case for covers in HassTurnOn/Off

* Enable light color/brightness on areas

* Remove async_register from default agent

* Remove CONFIG_SCHEMA from conversation component

* Fix intent tests

* Fix light test

* Fix humidifier intent handlers

* Remove DATA_CONFIG for conversation

* Copy ServiceIntentHandler code to light

* Add proper errors to humidifier intent handlers
2023-01-19 17:15:01 -06:00
Jan Bouwhuis 25392655e7
Allow translating select selector options (#85531)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2023-01-17 16:22:19 +01:00
Erik Montnemery 788edc21fb
Deduplicate some entity registry code (#85541) 2023-01-16 22:06:52 +01:00
Karlie Meads 156307f3f2
Fix logic of disabled condition for "OR" (#79718) 2023-01-16 21:08:09 +01:00
Allen Porter 1afb4897a8
Add a timeout during OAuth token exchange and additional debug logging (#85911) 2023-01-16 19:52:43 +01:00
Franck Nijhof 64c2340fab
Core code styling improvements (#85963) 2023-01-15 23:00:51 +01:00
Erik Montnemery 8983f665cf
Refactor device registry JSON cache (#85539) 2023-01-09 09:50:27 -10:00
Erik Montnemery b933a53aa3
Refactor entity registry JSON cache (#85085)
* Refactor entity registry JSON cache

* Fix generator

* Tweak

* Improve string building

* Improve test coverage

* Override EntityRegistryItems.values to avoid __iter__ overhead
2023-01-09 16:52:52 +01:00
Franck Nijhof 06a35fb7db
Code styling tweaks to core helpers (#85441) 2023-01-08 13:44:09 -10:00
J. Nick Koston a18a629c19
Avoid pattern search entry when there are no patterns in the entity filter (#85404) 2023-01-07 14:40:58 -10:00
Michael Hansen ecaec0332d
Hassil intents (#85156)
* Add hassil to requirements

* Add intent sentences

* Update sentences

* Use hassil to recognize intents in conversation

* Fix tests

* Bump hassil due to dependency conflict

* Add dataclasses-json package contraints

* Bump hassil (removes dataclasses-json dependency)

* Remove climate sentences until intents are supported

* Move I/O outside event loop

* Bump hassil to 0.2.3

* Fix light tests

* Handle areas in intents

* Clean up code according to suggestions

* Remove sentences from repo

* Use home-assistant-intents package

* Apply suggestions from code review

* Flake8

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-01-07 16:20:21 -05:00
J. Nick Koston 194adcde9c
Drop ChainMap in translation cache (#85260) 2023-01-06 11:52:18 -10:00
Marc Mueller 516cb31635
Fix multi inheritance with CoordinatorEntity (#85053) 2023-01-03 23:07:59 +01:00
J. Nick Koston d89c259d7e
Fix double time conversion in async_track_point_in_utc_time (#85036) 2023-01-03 20:21:54 +01:00
Marc Mueller 972eb34ed9
Improve `bluetooth` generic typing (#84891)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-01-02 21:19:53 -10:00
Franck Nijhof 5cfa98e400
Improve typing of SelectorConfig (#85022) 2023-01-02 18:52:15 -05:00
Erik Montnemery 11c174aca3
Revert "Add aliases to device registry items" (#84976) 2023-01-02 12:30:25 +01:00
Joakim Plate 5c43f0861f
Avoid running final writes in executor in test (#84679) 2022-12-28 23:40:11 +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
Erik Montnemery 1a42bd5c4c
Add aliases to area registry items (#84294)
* Add aliases to area registry items

* Update test

* Fix WS API
2022-12-21 08:44:44 +01:00
Erik Montnemery 057bb6ea0a
Add aliases to device registry items (#84246) 2022-12-20 23:43:31 +01:00
Erik Montnemery 1f3da9cf1a
Add aliases to entity registry items (#84239) 2022-12-20 12:10:46 +01:00
Erik Montnemery fd9124279b
Add minor version to area registry store (#84280) 2022-12-20 11:41:35 +01:00
Erik Montnemery f88ed6b69e
Use dict.setdefault in registry migration code (#84277) 2022-12-20 11:31:31 +01:00
Michaël Arnauts 7142b4ecac
Fixes some grammar mistakes (#84283) 2022-12-20 11:10:31 +01:00
Michael Hansen 98eabd2f68
Update intent response (#83962)
* Add language to conversation and intent response

* Move language to intent response instead of speech

* Extend intent response for voice MVP

* Add tests for error conditions in conversation/process

* Move intent response type data into "data" field

* Move intent response error message back to speech

* Remove "success" from intent response

* Add id to target in intent response

* target defaults to None

* Update homeassistant/helpers/intent.py

* Fix test

* Return conversation_id and multiple targets

* Clean up git mess

* Fix linting errors

* Fix more async_handle signatures

* Separate conversation_id and IntentResponse

* Add unknown error code

* Add ConversationResult

* Don't set domain on single entity

* Language is required for intent response

* Add partial_action_done

* Default language in almond agent

* Remove partial_action_done

* Fix linting

* Rename success/fail targets

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-12-13 23:32:30 -05:00
Michael Hansen 961c8cc167
Update intent response (#83858)
* Add language to conversation and intent response

* Move language to intent response instead of speech

* Extend intent response for voice MVP

* Add tests for error conditions in conversation/process

* Move intent response type data into "data" field

* Move intent response error message back to speech

* Remove "success" from intent response

* Add id to target in intent response

* target defaults to None

* Update homeassistant/helpers/intent.py

* Fix test

* Return conversation_id and multiple targets

* Clean up git mess

* Fix linting errors

* Fix more async_handle signatures

* Separate conversation_id and IntentResponse

* Add unknown error code

* Add ConversationResult

* Don't set domain on single entity

* Language is required for intent response

* Add partial_action_done

* Default language in almond agent

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-12-13 16:46:40 -06:00
Erik Montnemery cc132bfad6
Make it optional to provide a title when finishing a FlowHandler (#83534)
* Make it optional to provide a title when finishing a FlowHandler

* Make ConfigEntry.title a str

* Revert changes in ConfigFlow

* Adjust tests
2022-12-09 10:24:08 +01:00
Michael Hansen e71eb8dfe2
Update intent response (#83560)
* Add language to conversation and intent response

* Move language to intent response instead of speech

* Extend intent response for voice MVP

* Add tests for error conditions in conversation/process

* Move intent response type data into "data" field

* Move intent response error message back to speech

* Remove "success" from intent response

* Add id to target in intent response

* target defaults to None

* Update homeassistant/helpers/intent.py

* Fix test

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-12-08 20:30:08 -05:00
Erik Montnemery c4afc33fc5
Add abc.ABC to classes with abstract methods (#83546) 2022-12-08 17:50:36 +01:00
Michael Hansen ac87528bec
Add language to conversation and intent response (#83486)
* Add language to conversation and intent response

* Add language parameter to conversation/process service

* Move language to intent response instead of speech

* Add language to almond conversation agent

* Fix intent test
2022-12-08 11:39:28 -05:00
epenet 9f7fd8956f
Use new unit enums in helpers (#83387) 2022-12-06 22:20:17 +01:00
Erik Montnemery 8e617bbc1d
Add `translation_key` property to entites (#82701)
* Add translation_key attribute to entity state

* Update accuweather test

* Index entity translation keys by platform

* Store translation key in entity registry
2022-12-01 09:34:09 +01:00
Mike Degatano b3deb476ef
Allow is_state to accept a list of values (#81877)
* Allow is_state to accept a list of values

* Slightly more efficient

* Fix typing of state

Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-11-30 22:54:14 +01:00
epenet 98f263c289
Make SchemaFlowFormStep functions async (#82962)
* Make validate async in SchemaOptionsFlowHandler

* Adjust group

* Adjust tests

* Move all to async

* Adjust integrations

* Missed an integration

* Missed one

* Rebase to fix conflict
2022-11-30 12:26:52 +01:00
epenet 663482fb10
Add flow_state to SchemaCommonFlowHandler (#82967)
* Add local_context to SchemaCommonFlowHandler

* Rename to context

* Rename to flow_state
2022-11-30 10:18:57 +01:00
Marc Mueller 79b400d71b
Improve PluggableActionsEntry typing (#82885)
* Improve PluggableActionsEntry typing

* Add parameter typing
2022-11-29 13:37:22 +01:00
epenet 724a79a8e8
Add suggested_value helper for FlowHandler (#82491)
* Add suggested_value helper for ConfigFlow

* Move helper function to FlowHandler

* Rename and adjust docstring

* Fix rebase
2022-11-29 10:16:01 +01:00
epenet 53e05dec02
Add ability to add sensors in scrape config flow (#82802)
* Add ability to add sensors in scrape config flow

* Fix menu

* Adjust comment

* Use sentinel

* Adjust docstring
2022-11-29 10:13:38 +01:00
Marc Mueller 63d519c1a8
Spelling updates (#82867) 2022-11-28 16:51:43 +01:00
Erik Montnemery effa9940ff
Save migrated store data (#82523) 2022-11-28 09:42:08 -05:00
epenet a236836796
Fix typo in helper docstring (#82824) 2022-11-28 09:15:16 +01:00
Erik Montnemery 35dbc3151a
Fix docstring for entity helper (#82704)
Fix some language in entity.py
2022-11-25 18:20:33 +01:00
epenet 0a4549e202
Add callback to SchemaFlowFormStep for suggested_values (#82706)
* Allow callback for suggested_values

* docstring
2022-11-25 16:38:58 +01:00
Erik Montnemery e9ce08763c
Allow SchemaFlowFormStep.next_step to return None (#82707) 2022-11-25 16:00:26 +01:00
epenet fcba9974e5
Rename options to suggested_values (#82700) 2022-11-25 14:40:20 +01:00
epenet 6c615016b8
Fix None schema in SchemaCommonFlowHandler (#82699) 2022-11-25 14:30:02 +01:00
Franck Nijhof c715035016
Add support for raising ConfigEntryError (#82689) 2022-11-25 11:33:03 +01:00
epenet 9feb64cebd
Simplify schema callback in SchemaFlowFormStep (#82682)
* Simplify SchemaFlowFormStep.schema callback

* Expose parent handler

* Adjust docstrings
2022-11-25 10:50:38 +01:00
epenet a4dbb9a24e
Add handler to validate_user_input (#82681)
* Add handler to validate_user_input

* Adjust group config flow
2022-11-25 09:29:54 +01:00
Erik Montnemery e1338adf1a
Allow configuring country and language in core config (#81734)
* 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
G Johansson 6cb004b770
Selector for SingleEntitySelectorConfig allow domain to be a list (#82666) 2022-11-24 22:34:39 +01:00
epenet 9f9114cb4a
Simplify SchemaFlowStep typing (#82661)
* Simplify SchemaFlowStep typing

* Adjust accuweather
2022-11-24 21:59:41 +01:00
Erik Montnemery 978122c882
Fix docstring in SchemaFlowFormStep (#82612) 2022-11-24 20:30:23 +01:00
epenet 9132c42037
Improve Selector typing (#82636) 2022-11-24 19:27:26 +01:00
epenet caa99ea9fb
Allow next_step to be a string (#82647)
* Allow next_step to be a string

* Adjust docstrings

* Add test
2022-11-24 18:55:53 +01:00
Erik Montnemery 8577310e6d
Fix show_menu support in SchemaFlowFormStep (#82634)
* Fix show_menu support in SchemaFlowFormStep

* Add test

* Fix test
2022-11-24 17:30:01 +01:00
epenet e386bab682
Add type hint to template wrapper (#82563)
* Add type to template hassfunction decorator

* Adjust to use EvalContext

* Use runtime.Context

* Use TypeVar for context

* Use jinja2.runtime.Context

* Reverse declarations

* Use Any

* Update homeassistant/helpers/template.py

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2022-11-24 15:30:21 +01:00
epenet a856abf47f
Make async_options_flow_finished optional (#82615)
* Make async_options_flow_finished optional

* Adjust docstring
2022-11-24 14:43:40 +01:00
epenet ba18571cbe
Set last_step in SchemaCommonFlowHandler (#82616)
* Set last_step in SchemaCommonFlowHandler

* Always use boolean

* Adjust next_step definition
2022-11-24 14:37:55 +01:00
epenet 4c38a5d773
Add OptionsFlow helper class (#82531)
* Add OptionsFlow helper classes

* More integrations

* Adjust SchemaOptionsFlowHandler

* Use single class

* Simplify access to options

* Reduce PR

* Make _options private

* Add test
2022-11-24 12:18:09 +01:00
epenet b525259878
Add type hints to template result wrapper (#82575)
* Add type hints to template result wrapper

* Remove `ignore[call-arg]`

* Use tuple

* Alphabetise
2022-11-24 08:41:14 +01:00
On Freund 9dd1b85cbb
Allow `device_attr` and `is_device_attr` to be used as a filter and a test (respectively) (#81924)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2022-11-24 08:31:17 +01:00
epenet d7f0b904d0
Add type to template function (#82564) 2022-11-23 21:50:45 +01:00
epenet f91e250e90
Fix TemplateError definition (#82570) 2022-11-23 20:30:32 +01:00
Jan Bouwhuis 23bc39b7f4
Add type hints on `Template().__init__()` (#82574) 2022-11-23 20:26:55 +01:00
epenet aa02a53ac6
Add type hints to template states (#82582)
* Add type hints to template states

* Undo rename

* Remove invalid mypy issue link
2022-11-23 17:46:51 +01:00
epenet 687d162a94
Fix incorrect type hint in SchemaOptionsFlow (#82516) 2022-11-22 12:45:35 +01:00
epenet 9d192643ee
Move PluggableAction to trigger helpers (#81900)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Joakim Plate <elupus@ecce.se>
Co-authored-by: Shay Levy <levyshay1@gmail.com>
2022-11-22 11:35:18 +01:00
J. Nick Koston d0efdd750f
Fix high latency from thundering heard at 0 microseconds (#82233)
* Fix high latency at 0 microseconds

fixes #82231

* fix async_track_utc_time_change alignment

* use replace to preserve fold

* naming

* tweak

* make async_fire_time_changed aware of the thundering heard issue
2022-11-17 14:22:06 -05:00
Aarni Koskela 4f7b583f19
Fix shadowing of outer name in config_validation (#82088)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-11-16 14:04:57 +01:00
Aarni Koskela 8038485ca4
Use partition instead of split where possible in core (#81806) 2022-11-15 21:45:48 +01:00
Steve Repsher c940ad9920
Add autocomplete to text selector (#81060) 2022-11-15 12:58:59 -06:00
uvjustin e7dd31f37b
Iterate over entities safely in camera setup (#82080)
fixes undefined
2022-11-15 08:02:35 -06:00
Aarni Koskela 3d29638804
Deduplicate `sensor_device_info_to_device_info` (#81905)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-11-14 12:12:53 -06:00
epenet 9f691ab359
Revert "Fix coordinator TypeVar definition (#81298)" (#81834) 2022-11-09 09:03:59 +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
epenet 318122fe53
Fix coordinator TypeVar definition (#81298)
* Adjust coordinator TypeVar definition

* Adjust again
2022-11-08 10:38:29 +01:00
Erik Montnemery c3d4a9cd99
Create repairs issue if an outdated currency code is configured (#81717)
* Create repairs issue if an outdated currency code is configured

* Add script for updating list of currencies

* Use black for formatting

* Move currency codes to a separate file

* Address review comments
2022-11-08 07:21:09 +01:00
epenet 5e05739019
Add type hints to template helper (#81308)
* Add type hints to template helper

* Update homeassistant/helpers/template.py

* Adjust use of ensure_compiled
2022-11-07 09:41:53 +01:00
Petro31 f73fc9e355
Adds states and state_attr as a filter, adds is_state and is_state_attr as a test. (#79473) 2022-10-25 19:49:51 +02:00
Franck Nijhof 326344db12
Rename entry_id template method to config_entry_id (#80935) 2022-10-25 12:11:14 +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 eb93372cd6
Improve type hint in entity_component (#80596)
Imrpove type hint in entity_component
2022-10-20 12:38:22 +02:00
Marc Mueller d78c2a31a1
Update pylint to 2.15.4 (#80612) 2022-10-20 08:59:06 +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
Janick Bergeron f21a004aa9
Fix before sunrise OR after sunset condition (#76143)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Ben Randall <veleek@gmail.com>
2022-10-14 13:11:10 +02:00
HarvsG e5dafbc166
Make _TrackTemplateResultInfo not private (#79812) 2022-10-09 15:23:08 +02:00
Erik Montnemery 59d9d3de69
Add at_started helper (#79577) 2022-10-05 12:24:51 +02:00
Erik Montnemery 18033532ca
Fix search throwing on templated services (#79637) 2022-10-05 10:59:18 +03:00
ehendrix23 47b40e1e61
Add optional default value to average template function/filter (#77499)
* Return None on empty list

* Updated to use default value

* Update comment.
2022-10-03 10:07:19 +02:00
ehendrix23 ba6a81c565
Resolve traceback error when using variables in template triggers (#77287)
Co-authored-by: Erik <erik@montnemery.com>
2022-09-29 13:26:28 -04:00
Rami Mosleh e7764b8bf1
Add ConfigEntry template function (#78030)
* Add ConfigEntry template function

* Remove looking up entry_id by entry title
2022-09-29 12:41:59 +02:00
Raman Gupta 3884b4b6bf
Bump zwave-js-server-python to 0.42.0 (#79020) 2022-09-28 21:24:04 -04:00
epenet 24c26dc032
Use unit_conversion in components (#79204)
* Use unit_conversion in components

* Two more
2022-09-28 16:05:31 +02:00
Erik Montnemery c38b1e7727
Improve check of new_entity_id in entity_registry.async_update_entity (#78276)
* Improve check of new_entity_id in entity_registry.async_update_entity

* Fix race in rfxtrx config flow

* Make sure Event is created on time

* Rename poorly named variable

* Fix typing

* Correct typing of _handle_state_change
2022-09-28 08:43:58 +02:00
Erik Montnemery 7ead77eea6
Correct typing of async_track_state_change (#79150)
* Correct typing of async_track_state_change

* Update integrations
2022-09-27 16:32:54 +01:00
Erik Montnemery 53263ea9bc
Revert "Add serial_number to device registry entries" (#79139) 2022-09-27 16:36:38 +02:00
Erik Montnemery cba3b6ad94
Add serial_number to device registry entries (#77713) 2022-09-27 09:08:54 +02:00
Marc Mueller faad904cbc
Remove unnecessary boolean checks for callables (#78819) 2022-09-25 22:01:27 -04: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
J. Nick Koston 8dbbd0ded0
Cache template regex compiles (#78529) 2022-09-18 11:48:04 +02:00
epenet 8300f8234c
Make async_extract_entities generic (#78490) 2022-09-16 00:20:47 +02:00
Joakim Sørensen 8dbe293ae2
Add version to templates (#78484) 2022-09-15 15:01:40 +02:00
epenet 0a13fe99d2
Move mypy override for device_registry (#78493) 2022-09-15 11:00:25 +02:00
Erik Montnemery 84a812ad05
Allow setting number selector step size to 'any' (#78265)
* Allow setting number selector step size to 'any'

* Improve test coverage
2022-09-15 08:29:46 +02:00
epenet 996bcbdac6
Make EntityComponent generic (#78473) 2022-09-14 14:16:23 -04:00
epenet d3be06906b
Improve type hints in script helpers (#78364)
* Improve type hints in script helpers

* Import CONF_SERVICE_DATA from homeassistant.const

* Make data optional
2022-09-13 23:11:29 +02:00
Erik Montnemery 4e32bf2ac9
Drop old migration code from entity registry (#78278) 2022-09-12 22:28:05 -04:00
Erik Montnemery e332091d76
Improve unique_id collision checks in entity_platform (#78132) 2022-09-09 14:35:23 +02:00
J. Nick Koston 363f95c954
Remove auto lowercasing from async_track_entity_registry_updated_event (#77740) 2022-09-05 12:13:05 +02:00
Erik Montnemery b0d033ef29
Add mixin class CollectionEntity for the collection helper (#77703)
* Add mixin class CollectionEntity for the collection helper

* Improve typing

* Address review comments

* Fix tests
2022-09-03 12:56:49 +02:00
Erik Montnemery 56278a4421
Simplify device registry (#77715)
* Simplify device registry

* Fix test fixture

* Update homeassistant/helpers/device_registry.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Update device_registry.py

* Remove dead code

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-09-03 12:50:55 +02:00
Erik Montnemery 3a86209dec
Remove unnecessary use of dunder methods from entity registry (#77716) 2022-09-02 17:02:14 +00:00
Erik Montnemery 1bc8770b51
Remove area_id from entity_registry.async_get_or_create (#77700)
* Remove area_id from entity_registry.async_get_or_create

* Adjust tests

* Fix lying comment in test
2022-09-02 13:31:05 +02:00
Erik Montnemery 8924725d69
Improve some device registry tests (#77659) 2022-09-02 08:54:02 +02:00
Erik Montnemery cd2045b66d
Clean up user overridden device class in entity registry (#77662) 2022-09-01 11:45:19 -04:00
Erik Montnemery 4655ed995e
Fix resetting of attributes in EntityRegistry.async_get_or_create (#77516)
* Fix resetting of attributes in EntityRegistry.async_get_or_create

* Fix typing

* Fix resetting config entry

* Improve test

* Update tests
2022-08-30 21:07:50 +02:00
Paulus Schoutsen 14f68ec1a9
Store redirect URI in context instead of asking each time (#77380)
* Store redirect URI in context instead of asking each time

* Fix tests
2022-08-29 19:28:42 -04:00
J. Nick Koston 4333d9a7d1
Fix recorder being imported before deps are installed (#77460) 2022-08-28 22:18:35 -05:00
Marc Mueller 1210897f83
Update pylint to 2.15.0 (#77408)
* Update pylint to 2.15.0

* Remove useless suppressions

* Fix TypeVar name
2022-08-28 21:14:09 +02:00
Joakim Sørensen 0caf998547
Bump awesomeversion from 22.6.0 to 22.8.0 (#77436) 2022-08-28 14:52:23 -04:00
Franck Nijhof dfc3e7d80f
Don't expose attribute option in state selector (#77347) 2022-08-26 11:51:36 +02:00
Erik Montnemery dfed3ba75e
Move issue_registry to homeassistant.helpers (#77299)
* Move issue_registry to homeassistant.helpers

* Add backwards compatibility
2022-08-25 11:32:06 +02:00
Franck Nijhof 4d02cccd11
Fix typing of ConfigEntrySelector (#77259) 2022-08-24 15:15:29 +02:00
Franck Nijhof dc17bca00c
Add config entry selector (#77108) 2022-08-24 00:29:30 +02:00
Franck Nijhof 9843753f30
Add alias support to all triggers (#77184) 2022-08-22 17:43:09 -04:00
Franck Nijhof 5a0e4fa5ee
Add hide attribute support to attribute selector (#77072)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-08-22 12:55:30 +02:00
Franck Nijhof 453307e01a
Add attribute support to state selector (#77071) 2022-08-20 13:30:38 -04:00
Franck Nijhof 2d197fd59e
Add state selector (#77024)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-08-19 09:24:53 -04:00
Paulus Schoutsen 6e92931087
Add file selector and file upload integration (#76672) 2022-08-18 12:02:12 -04:00
Marc Mueller c93d9d9a90
Move `AutomationActionType` to helpers.trigger (#76790) 2022-08-15 08:37:11 -04:00
Paulus Schoutsen 2f29f38ec6
Streamline discovery flow callback (#76666) 2022-08-12 16:42:41 -07:00
Franck Nijhof a30dfd9f3e
Add class attribute for capability attributes in entity base class (#76599) 2022-08-11 10:34:58 +02:00
Marc Mueller dc47121f2c
Better type hass_job method calls (#76053) 2022-08-09 16:12:33 -04:00
J. Nick Koston 80a9659524
Update to bleak 0.15 (#75941) 2022-07-29 17:53:33 -07:00
Marc Mueller af7df260a0
Fix small type issues [core] (#75760) 2022-07-26 16:28:22 +02:00
J. Nick Koston 8300d5b89e
Add bluetooth connection constant to the device registry (#75666) 2022-07-23 19:59:35 +02:00
Erik Montnemery fd6ffef52f
Support non-live database migration (#72433)
* Support non-live database migration

* Tweak startup order, add test

* Address review comments

* Fix typo

* Clarify comment about promoting dependencies

* Tweak

* Fix merge mistake

* Fix some tests

* Fix additional test

* Fix additional test

* Adjust tests

* Improve test coverage
2022-07-22 15:11:34 +02:00
Marc Mueller b1ed1543c8
Improve http decorator typing (#75541) 2022-07-21 13:07:42 +02: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 51ed9ee59d
Fix bluetooth service_info typing (#75477)
* Fix bluetooth service_info typing

* Remove additional type ignores

* Remove pylint disable
2022-07-20 05:46:18 +02:00
Marc Mueller 8a48d54951
Improve entity_platform helper typing (#75464)
* Improve entity_platform helper typing

* Add protocol class

* Apply suggestions from code review

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

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-07-20 05:45:57 +02:00
Marc Mueller 1626c53c13
Improve dispatcher helper typing (#75455)
* Improve dispatcher helper typing

* Code review
2022-07-20 04:11:46 +02:00
Marc Mueller d09fff595c
Rename existing TypeVars referencing Self type (#75473) 2022-07-20 03:03:22 +02:00
Marc Mueller b04c3e9adc
Improve deprecation helper typing (#75453) 2022-07-20 02:54:46 +02:00
Marc Mueller 5ae5ae5392
Improve debouncer typing (#75436) 2022-07-19 18:35:04 +02:00
Franck Nijhof e65018fb85
Clean up deprecated connection class remainders (#75421) 2022-07-18 21:14:41 -07:00
Franck Nijhof 7adb0f0ef5
Custom component -> Custom integration (#75404) 2022-07-18 22:10:22 +02:00
J. Nick Koston ba8a530d19
Use shared bluetooth models for BluetoothServiceInfo (#75322) 2022-07-16 21:14:23 -07:00
J. Nick Koston ecc219fbc1
Include the source in the bluetooth service info (#75112) 2022-07-16 11:02:08 -05:00
J. Nick Koston 03e3ebb238
Use json_loads by default for the aiohttp helper (#75214) 2022-07-14 15:37:12 -05:00
J. Nick Koston 61cc9f5288
Consolidate executor jobs when loading integration manifests (#75176) 2022-07-14 13:06:08 -07:00
J. Nick Koston fde3489e86
Relocate BluetoothServiceInfo to helpers.service_info (#75195) 2022-07-14 11:36:54 -07:00
J. Nick Koston 666f715e76
Avoid importing MQTT into core for ServiceInfo dataclass (#74418)
* Avoid importing MQTT into core for discovery dataclass

Likely fixes #73863

* relo

* adjust

* rename

* rename

* rename

* adjust missed imports

* drop compat

* fix conflict correctly

* Update homeassistant/helpers/config_entry_flow.py

* fix black from trying to fix the conflict in github
2022-07-14 11:09:09 -05:00
Erik Montnemery 2e228b2608
Tweak handling of entities with `has_entity_name` set (#74948)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-07-11 15:10:53 -07:00
J. Nick Koston da027fa390
JSON serialize NamedTuple subclasses with aiohttp (#74971) 2022-07-11 14:46:55 -07:00
Allen Porter f4e61eff18
Add update coordinator for google calendar (#74690)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-07-10 21:24:52 -07:00
epenet 16900dcef1
Make Store a generic class (#74617) 2022-07-09 22:32:57 +02:00
J. Nick Koston a697672944
Add bluetooth integration (#74653)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-07-08 18:55:31 -05:00
J. Nick Koston 1dd9e705f2
Switch dispatcher to use async_run_hass_job (#74514)
* Switch dispatcher to use async_run_hass_job

- Since we already wrap all the callbacks in catch_log_exception
  we can use async_run_hass_job here

- The overhead of wrapping the call in a call_soon, queuing it
  and running it later usually exceeds the overhead of running
  the job itself

* fix size change during iteration

* fix out of order send

* fix missing mocking in unifi test

* Fix Legrand Home+ Control updating entities before the coordinator update had finished

* stray debug
2022-07-07 10:39:05 -05:00
J. Nick Koston e7b2d4672c
Avoid loading mqtt for type checking (#74464) 2022-07-05 10:27:27 -07:00
J. Nick Koston 6c3baf03aa
Make dispatcher setup lazy (#74374) 2022-07-04 14:58:35 +02:00
J. Nick Koston e2fe1a1c5d
Allow tuple subclasses to be json serialized (#74207) 2022-06-29 19:14:56 -05:00
Erik Montnemery 00810235c9
Track tasks adding entities (#73828)
* Track tasks adding entities

* Update homeassistant/config_entries.py

* fix cast tests

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-29 09:38:35 +02:00
Erik Montnemery 146ff83a16
Migrate rest binary_sensor and switch to TemplateEntity (#73307) 2022-06-28 13:53:38 -07:00
J. Nick Koston a8349a4866
Adjust entity filters to make includes stronger than excludes (#74080)
* Adjust entity filters to make includes stronger than excludes

Fixes #59080

* adjust test for stronger entity glob includes

* sync with docs
2022-06-28 11:42:51 -05:00
Erik Montnemery 26a85c6644
Add Entity.has_entity_name attribute (#73217) 2022-06-28 09:38:05 -07:00
J. Nick Koston 2225d0e899
Enable serialization of float subclasses with orjson (#74136) 2022-06-28 17:07:40 +02:00
[pʲɵs] 0e9164b082
Add bool template filter and function (#74068)
Co-authored-by: Erik <erik@montnemery.com>
2022-06-28 16:22:09 +02:00
J. Nick Koston 949922ef2c
Fix exception when as_dict is called on a TemplateState (#73984) 2022-06-25 09:19:11 -07:00
J. Nick Koston 32e0d9f47c
Speed up generation of template states (#73728)
* Speed up generation of template states

* tweak

* cache

* cache hash

* weaken

* Revert "weaken"

This reverts commit 4856f50080.

* lower cache size as it tends to be the same ones over and over

* lower cache size as it tends to be the same ones over and over

* lower cache size as it tends to be the same ones over and over

* cover

* Update homeassistant/helpers/template.py

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

* id reuse is possible

* account for iterting all sensors

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-06-24 17:28:26 -04:00
J. Nick Koston edb386c736
Switch frontend to use json helper (#73874) 2022-06-23 20:19:13 +02:00
J. Nick Koston 8015bb98a9
Switch recorder and templates to use json helper (#73876)
- These were using orjson directly, its a bit cleaner
  to use the helper so everything is easier to adjust
  in the future if we need to change anything about
  the loading
2022-06-23 14:32:26 +02:00
J. Nick Koston 164eba7e5d
Switch loader to use json helper (#73872) 2022-06-22 21:57:38 -05:00
J. Nick Koston ab30d38469
Switch rest to use the json helper (#73867) 2022-06-22 20:12:48 -05:00
Franck Nijhof a8a033681f
Automatically onboard DiscoveryFlows (#73841) 2022-06-22 22:37:49 +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
epenet a92105171c
Remove vizio from mypy ignore list (#73585)
* Remove vizio config_flow from mypy ignore list

* Fix mypy errors

* Adjust media_player

* Add space
2022-06-19 21:39:24 +02:00
Allen Porter b014d558ff
Add application credentials platform for nest and deprecate yaml for SDM API (#73050)
* Update the nest integration to be useable fully from the config flow

* Support discovery in nest config flow

* Remove configuration entries

* Remove unused import

* Remove dead code

* Update homeassistant/components/nest/strings.json

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

* Remove commented out code

* Use config flow for app auth reauthentication path

* Improves for re-auth for upgrading existing project and creds

* More dead code removal

* Apply suggestions from code review

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

* Remove outdated code

* Update homeassistant/components/nest/config_flow.py

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

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-15 07:15:53 -07:00
J. Nick Koston 9b157f974d
Reduce overhead to refire events from async_track_point_in_utc_time when an asyncio timer fires early (#73295)
* Reduce overhead to refire events

- asyncio timers can fire early for a varity of reasons including
  poor clock resolution and performance. To solve this problem
  we re-arm async_track_point_in_utc_time and try again later
  when this happens.

- On some platforms this means the async_track_point_in_utc_time can
  end up trying many times to prevent firing the timer early since as
  soon as it rearms it fires again and this repeats until we reach
  the appointed time. While there is not much we can do to prevent
  asyncio from firing the timer callback early, we can reduce the
  overhead when this happens by using avoiding creating datetime
  objects

* tweak mocking

* -vvv

* fix time freeze being too broad in litterrobot

* adjust
2022-06-14 07:46:00 -10:00
J. Nick Koston 034c0c0593
Improve YAML Dump times with C Dumper (#73424) 2022-06-13 13:14:30 -07:00
Erik Montnemery 4435c641de
Enforce RegistryEntryHider in entity registry (#73219) 2022-06-08 12:36:43 -07:00
Erik Montnemery 921245a490
Remove deprecated temperature conversion of non sensors (#73222) 2022-06-08 20:47:47 +02:00
Erik Montnemery 5987266e56
Refactor template entity to allow reuse (#72753)
* Refactor template entity to allow reuse

* Fix schema and default name

* Add tests

* Update requirements

* Improve test

* Tweak TemplateSensor initializer

* Drop attributes and availability from TemplateEntity

* Use rest sensor for proof of concept

* Revert changes in SNMP sensor

* Don't set _attr_should_poll in mixin class

* Update requirements
2022-06-08 15:55:49 +02:00
epenet f91aa33c5f
Add FlowResultType enum to data entry flow (#72955) 2022-06-07 22:02:44 -07:00
Marc Mueller 983a76a91c
Update pylint to 2.14.0 (#73119) 2022-06-06 21:43:47 +02:00
Raphaël Beamonte 88129dbe91
Allow `log` template function to return specified `default` on math domain error (#72960)
Fix regression for logarithm template
2022-06-03 15:27:10 +02:00
Joakim Plate 8910d265d6
Keep track of a context for each listener (#72702)
* Remove async_remove_listener

This avoids the ambuigity as to what happens if same callback is added multiple times.

* Keep track of a context for each listener

This allow a update coordinator to adapt what data to request on update from the backing service based on which entities are enabled.

* Clone list before calling callbacks

The callbacks can end up unregistering and modifying the dict while iterating.

* Only yield actual values

* Add a test for update context

* Factor out iteration of _listeners to helper

* Verify context is passed to coordinator

* Switch to Any as type instead of object

* Remove function which use was dropped earliers

The use was removed in 8bee25c938
2022-06-03 13:55:57 +02: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
Joakim Plate 84779482b8
Don't set headers kwargs multiple times (#72779) 2022-05-31 13:08:50 -07:00
J. Nick Koston d9d22a9556
Initial orjson support (#72754) 2022-05-31 12:18:11 -07:00
Malte Franken 638992f9c4
Make zone condition more robust by ignoring unavailable and unknown entities (#72751)
* ignore entities with state unavailable or unknown

* test for unavailable entity
2022-05-31 11:34:52 -07:00
Marc Mueller b417ae72e5
Add generic parameters to HassJob (#70973) 2022-05-30 09:22:37 +02:00
Paulus Schoutsen 6a3d2e54a2
Handle OAuth2 rejection (#72040) 2022-05-28 20:23:16 -07:00
Paulus Schoutsen d59258bd25
Revert "Add service entity context (#71558)" (#72610) 2022-05-27 10:30:40 -07:00
Franck Nijhof 38ad1ef233
Use My Home Assistant for OAuth2 redirect callbacks (#72449)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-05-24 19:00:36 -07:00
Kevin Stillhammer 90e5d69184
Add template as_timedelta (#71801) 2022-05-23 19:32:22 +02:00
Erik Montnemery deedbca46c
Mark unused sync toggle method from ToggleEntity as final (#72370) 2022-05-23 17:52:21 +02:00
epenet 5cfb31d28a
Adjust device_automation type hints in core components (#72207) 2022-05-23 16:07:34 +02:00
epenet 99941b1c32
Warn on use of deprecated async_get_registry (#72088)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-05-18 12:04:06 -07:00
epenet 50ca14538a
Cleanup deprecated async_get_registry in core (#72087) 2022-05-18 17:58:28 +02:00
Allen Porter 26ee289be3
Add return code to integration application credentials in config flow (#71986)
* Add return code to integration application credentials in config flow

* Update google tests to use new return code

* Update spotify test for no auth configured

* Add translation for oauth2_missing_credentials

* Add new return code to yolink

* Update homeassistant/strings.json

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

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-05-18 06:30:57 -07:00
Franck Nijhof bfb47eb212
Final clean up of helpers accessed via hass (#72032)
* Final clean up of helpers accessed via hass

* Fix circular dep

* Fix import
2022-05-17 23:42:37 +03:00
Franck Nijhof 5f44d0f8f9
Clean up accessing storage.Store helper via hass (#72009) 2022-05-17 18:45:57 +02:00
Franck Nijhof 69cc6ab5f1
Clean up accessing entity_registry.async_get_registry helper via hass (#72005) 2022-05-17 16:40:45 +02:00
Franck Nijhof 7d2deae592
Clean up use of deprecated async_get_registry methods (#72001) 2022-05-17 13:40:19 +02:00
J. Nick Koston a614ddca28
Support requesting translations for multiple integrations in a single request (#71979) 2022-05-17 01:23:11 -05:00
Paulus Schoutsen 3b88c6c012
Inverse parallel updates default check, follow sync "update" method (#71720) 2022-05-16 17:10:34 -07:00
Erik Montnemery 4885331509
Fail template functions when no default specified (#71687) 2022-05-13 09:46:49 -07:00
Paulus Schoutsen 64636a4310
Add service entity context (#71558)
Co-authored-by: Shay Levy <levyshay1@gmail.com>
2022-05-09 14:45:53 -07:00
J. Nick Koston 30fdfc454f
Avoid lowercasing entities after template ratelimit recovery (#71415) 2022-05-09 12:48:38 +02:00
Joakim Plate 2dbe910e31
Adjust warning for missing entites (#71343) 2022-05-09 12:37:24 +02:00
Paulus Schoutsen e35a5a1a28
Fix other enums in helpers (#71505) 2022-05-07 20:57:48 -07:00
Paulus Schoutsen b1a04302b5
Stringify enums in selectors (#71441) 2022-05-06 11:25:01 -07:00
Paulus Schoutsen c8f95b7dfc
Ignore loading system entity category (#71361) 2022-05-05 14:33:37 -07:00
Paulus Schoutsen 353cc0b8c2
Fix importing blueprints (#71365)
Co-authored-by: Shay Levy <levyshay1@gmail.com>
2022-05-05 14:33:17 -07:00
Erik Montnemery eba125b093
Ensure 'this' variable is always defined for template entities (#70911) 2022-05-03 07:43:44 -07:00
Franck Nijhof 99360ad7f4
Indicate disabled steps in script trace (#71237) 2022-05-03 13:04:59 +02:00
Erik Montnemery 92f1855bcf
Fix script conditions (#71235) 2022-05-03 11:28:08 +02:00
Erik Montnemery 1931600eac
Isolate parallel subscripts (#71233) 2022-05-03 10:36:58 +02:00
Erik Montnemery 1aaf78ef99
Remove entity category system in favor of hidden_by (#68550) 2022-05-02 09:33:16 -07:00
Franck Nijhof a4682ae6e1
Adjust version number in template default deprecation warning (#71203) 2022-05-02 18:35:37 +03:00
Erik Montnemery f35e7d1129
Allow cancelling async_at_start helper (#71196) 2022-05-02 07:41:14 -07:00
Erik Montnemery f6c2fb088c
Stop script if sub-script stops or aborts (#71195) 2022-05-02 14:59:58 +02:00
Allen Porter 00b5d30e24
Add application credentials platform (#69148)
* Initial developer credentials scaffolding
- Support websocket list/add/delete
- Add developer credentials protocol from yaml config
- Handle OAuth credential registration and de-registration
- Tests for websocket and integration based registration

* Fix pydoc text

* Remove translations and update owners

* Update homeassistant/components/developer_credentials/__init__.py

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

* Update homeassistant/components/developer_credentials/__init__.py

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

* Remove _async_get_developer_credential

* Rename to application credentials platform

* Fix race condition and add import support

* Increase code coverage (92%)

* Increase test coverage 93%

* Increase test coverage (94%)

* Increase test coverage (97%)

* Increase test covearge (98%)

* Increase test coverage (99%)

* Increase test coverage (100%)

* Remove http router frozen comment

* Remove auth domain override on import

* Remove debug statement

* Don't import the same client id multiple times

* Add auth dependency for local oauth implementation

* Revert older oauth2 changes from merge

* Update homeassistant/components/application_credentials/__init__.py

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

* Move config credential import to its own fixture

* Override the mock_application_credentials_integration fixture instead per test

* Update application credentials

* Add dictionary typing

* Use f-strings as per feedback

* Add additional structure needed for an MVP application credential

Add additional structure needed for an MVP, including a target
component Xbox

* Add websocket to list supported integrations for frontend selector

* Application credentials config

* Import xbox credentials

* Remove unnecessary async calls

* Update script/hassfest/application_credentials.py

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

* Update script/hassfest/application_credentials.py

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

* Update script/hassfest/application_credentials.py

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

* Update script/hassfest/application_credentials.py

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

* Import credentials with a fixed auth domain

Resolve an issue with compatibility of exisiting config entries when importing
client credentials

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-30 08:06:43 -07:00
Franck Nijhof 682ac52a20
Support shorthand logical operators in script sequences (#71022) 2022-04-29 18:06:21 +02:00
Marc Mueller 283c04e424
Improve typing [helpers.entity] (#70890) 2022-04-28 10:52:42 +02:00
Marc Mueller 93cbb331e5
Update Mypy to 0.950 (#70948)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-04-27 20:49:54 -05:00
Marc Mueller 964c764dae
Improve typing [helpers.sun] (#70892) 2022-04-27 17:19:46 +02:00
Marc Mueller 7dfe8591c4
Improve typing [helpers.event] (#70891) 2022-04-27 17:19:06 +02:00
Erik Montnemery c5d69ab1b2
Handle removed entites in collection.sync_entity_lifecycle (#70759)
* Handle removed entites in collection.sync_entity_lifecycle

* Add comment
2022-04-27 08:05:00 -07:00
Marc Mueller 97af164858
Prepare for upcoming mypy update (#70800) 2022-04-26 07:41:52 -07:00
Paulus Schoutsen 5317bf02e6
Fix hidden default (#70699) 2022-04-25 10:10:42 -07:00
Erik Montnemery f6d9c75476
Remove metadata from device conditions and triggers (#70695) 2022-04-25 09:48:24 -07:00
Marc Mueller 9b9b553521
Disable no-self-use [pylint] (#70641)
* Disable no-self-use

* Remove disable comments
2022-04-25 07:41:01 -07:00
Dave T 70e125850c
Limit autogenerated entity_id string length (#69739) 2022-04-21 22:39:51 -07:00
Franck Nijhof 7b75a16745
Add visible by default property to base Entity (#70370) 2022-04-21 22:06:34 -07:00
Marc Mueller 90dab235f7
Update pylint to 2.13.7 (#70381)
* Update pylint to 2.13.7

* Spelling

* Remove old pylint config value

* Code updates
2022-04-21 13:02:52 -07:00
Franck Nijhof 35687def02
Merge stop & error script actions (#70109) 2022-04-20 14:22:37 -07:00