Commit Graph

286 Commits (fbec61662bec324b36720d9febea94c140afb96b)

Author SHA1 Message Date
G Johansson 666e8e133e
Cover state is enum (#127144)
* Change light state to use enum

* Adjust cover tests

* Update cover

* Fix covers

* Some tests

* More tests

* Fix tests

* Fix
2024-10-08 18:39:04 +02:00
Tudor Sandu d9b077154e
Blueprints for template entities (#126971)
* Template domain blueprints

* Default blueprint for templates

* Some linting

* Template entity updates

* Load and use blueprints in config

* Added missing mapping methods for templates

* Linting

* Added tests

* Wrong schema type

* Hassfest errors

* More linting issues

* Refactor based on desired schema

In the [architecture discussion](https://github.com/home-assistant/architecture/discussions/1027), the template blueprint instance did not specify the platform (e.g. `binary_sensor`), but the initial implementation assumed that schema.

* Create default template blueprints on first run

* Moved TemplateConfig definition

This is to avoid circular references

* Corrected methods to find templates based on blueprints

* Corrected missing entity config information

* Added tests

* Don't use hass.data

Address comments https://github.com/home-assistant/core/pull/126971/#discussion_r1780097187

* Prevent creating blueprints during testing

* Combine 2 ifs

Address comment https://github.com/home-assistant/core/pull/126971/#discussion_r1780160870

* Improve test coverage

* Prevent template component from dirtying test env

* Remove useless hard-coded validation

* Improve code coverage to 100%

* Address review comments

* Moved helpers in helpers.py

As per comment https://github.com/home-assistant/core/pull/126971#discussion_r1786539889

* Fix blueprint source URL

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-10-04 16:47:29 +02:00
Paul Bottein c306ebed49
Fix device id support for alarm control panel template (#127340) 2024-10-02 19:04:36 +02:00
epenet 6c539cd2d8
Improve type hints in template config_flow tests (#126803)
Improve type hints in template tests
2024-09-26 19:25:33 +02:00
epenet 5fb9537d6d
Use pytest.mark.usefixtures for start_ha in template tests (#126805) 2024-09-26 14:00:52 +02:00
G Johansson 93aade6e8e
Change lock state to an enum (#126379)
* Add new LockState enum for lock states

* Add rest

* Fix insteon tests

* Fix mqtt tests

* Fix tesla_fleet

* Revert back ST_STATE_LOCKED

* Add back constant
2024-09-24 12:30:50 +02:00
G Johansson 2080b9a87c
Add config flow to template alarm_control_panel (#125861)
* Add config flow to template alarm_control_panel

* Remove commented code

* Test import
2024-09-13 22:12:16 +02:00
G Johansson d855f70e3b
Add RestoreEntity to template alarm_control_panel (#125844) 2024-09-13 16:44:48 +02:00
chammp b3377fe5fb
Add condition to trigger template entities (#119689)
* Add conditions to trigger template entities

* Add tests

* Fix ruff error

* Ruff

* Apply suggestions from code review

* Deduplicate

* Tweak name used in debug message

* Add and improve type annotations of modified code

* Adjust typing

* Adjust typing

* Add typing and remove unused parameter

* Adjust typing

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

* Adjust return type

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

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-09-11 09:36:49 +02:00
chammp 56dfb2c734
Add unit_of_measurement to template numbers (#122862) 2024-09-11 08:47:17 +02:00
Sergey Dudanov dcd7830a35
Add calories to energy sensor device class (#122796)
* added calories to energy class

* changes

* temporarily solving the problem with conversion accuracy

* add tests

* added calories to energy class

* changes

* add tests

* Update homeassistant/util/unit_conversion.py

Co-authored-by: Robert Resch <robert@resch.dev>

* Update homeassistant/util/unit_conversion.py

Co-authored-by: Robert Resch <robert@resch.dev>

* apply suggestions

* Update homeassistant/util/unit_conversion.py

---------

Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-09-10 12:22:15 +02:00
epenet af6434a533
Add alias to DOMAIN import in tests [n-z] (#125581) 2024-09-09 15:14:05 +02:00
Jason Hunter 513361ef0f
Fix failing template config flow tests (#125534)
fix: failing template config flow tests
2024-09-08 21:38:31 +02:00
Erik Montnemery cf049a07c2
Don't allow templating min, max, step in config entry template number (#125342) 2024-09-06 07:59:22 +02:00
Joost Lekkerkerker 8c2e63807c
Make set_value required in number template (#124917)
* Make set_value required in number template

* Make set_value required in number template

* Fix tests
2024-08-30 22:02:10 +02:00
epenet 3dc83ef19d
Add missing hass type hint in component tests (t) (#124274) 2024-08-20 12:55:39 +02:00
dougiteixeira f581066747
Add config flow for platform number in Template (#121849)
* Add config flow to select platform in Template

* Remove device id duplicate in schema

* Add config flow for number platform in Template

* Remove mode
2024-08-15 20:02:51 +02:00
epenet 67f761c0e9
Improve type hints in template tests (#123915) 2024-08-14 14:58:16 +02:00
Erik Montnemery dc462aa529
Remove unnecessary assignment of Template.hass from template (#123773) 2024-08-13 11:54:36 +02:00
Joost Lekkerkerker e8d7eb05ae
Delete unused snapshots (#123656)
* Delete unused snapshots

* Delete unused snapshots
2024-08-12 13:28:09 +02:00
Erik Montnemery b973455037
Fix template image test affecting other tests (#122849) 2024-07-30 16:28:55 +02:00
Erik Montnemery d9e996def5
Fix template binary sensor test (#122855) 2024-07-30 16:18:47 +02:00
Marc Mueller a6068dcdf2
Update import locations in tests (#122216) 2024-07-20 11:16:04 +02:00
dougiteixeira 162b734be7
Add config flow for select platform in Template (#121809) 2024-07-12 17:50:02 +02:00
dougiteixeira 52454f5218
Add config flow for platform switch in Template (#121639) 2024-07-11 10:11:31 +02:00
dougiteixeira e0c7073da1
Add config flow for image platform in Template (#121648) 2024-07-10 23:49:24 +02:00
dougiteixeira d783813ba0
Add config flow for platform button in Template (#120886) 2024-07-09 21:20:18 +02:00
dougiteixeira 4289efb506
Device change test improvements in Template (#120884) 2024-07-05 14:47:31 +02:00
dougiteixeira 10edf85311
Update `test_device_cleaning` in Template (#120163) 2024-06-22 15:59:46 +02:00
dougiteixeira 6e32a96ff3
Add the ability to bind the template helper entity to a device (#117753) 2024-06-22 12:45:06 +02:00
G Johansson b6b6248713
Remove legacy get forecast service from Weather (#118664)
* Remove legacy get forecast service from Weather

* Fix tests

* Fix test

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-06-17 21:13:28 +02:00
epenet 3d1165519d
Fix broad-exception-raised in component tests (#119467) 2024-06-12 17:53:42 +02:00
epenet 99b349fa2c
Fix consider-using-dict-items warnings in tests (#119497) 2024-06-12 16:44:29 +02:00
epenet fb1b0058ee
Fix consider-using-tuple pylint warnings in component tests (#119464)
* Fix consider-using-tuple pylint warnings in component tests

* Apply su

Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>

---------

Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
2024-06-12 15:50:27 +02:00
chammp 52379ad7cb
Add code_format_template to template locks (#106947)
* Add code_format to template locks

* Replace code_format with code_format_template

* Add test case for template eval to None

* Apply suggestion to not call super()

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

* Add more negative tests

* Handle template render errors

* Better error message

* Add custom test lock config for code format

* Add type hints from upstream

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2024-06-10 16:54:17 +02:00
epenet c896458fcf
Fix namespace-import pylint warning in components (#119299) 2024-06-10 15:55:08 +02:00
epenet c7cc465e5c
Add return type hints in tests (k-z) (#118942) 2024-06-06 10:11:29 +02:00
epenet 166c588cac
Add LogCaptureFixture type hints in tests (#118372) 2024-05-29 14:10:00 +02:00
G Johansson 6b7ff2bf44
Add default code to alarm_control_panel (#112540) 2024-05-29 10:46:53 +02:00
epenet bead6b0094
Rename service_calls fixture in template tests (#118358) 2024-05-29 10:27:52 +02:00
epenet 98d24dd276
Improve typing for `calls` fixture in tests (m-z) (#118350)
* Improve typing for `calls` fixture in tests (m-z)

* More

* More
2024-05-29 09:30:41 +02:00
Sid 9bf87329da
Enable Ruff FLY002 rule (#115112)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-04-12 09:04:16 +02:00
J. Nick Koston d321906342
Always run keyed event trackers immediately (#114709) 2024-04-04 15:30:01 -10:00
Joost Lekkerkerker ee66f6ec8c
Use is in enum comparison in config flow tests P-T (#114675) 2024-04-02 11:21:50 -10:00
Sid d5f883fbf0
Unignore Ruff PLR in tests (#114470)
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Sid aec7a67a58
Unignore Ruff PLE, PLW in tests (#114406)
* Unignore Ruff PLE, PLW in tests

* fix tests
2024-03-29 23:58:30 +01:00
G Johansson 65230908c6
Remove deprecated forecast attribute from WeatherEntity (#110761)
* Remove deprecated forecast attribute from WeatherEntity

* Fix some

* Ruff

* ipma

* buienradar

* some more

* Some more

* More and more

* strings

* attr_forecast

* Fix nws

* Fix

* remove from coverage

* Remove recorder test

* Review comments
2024-03-27 16:51:29 +01:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
J. Nick Koston b574220247
Refactor rate limit helper to track time in seconds (#113898)
* Refactor rate limit helper to track time in seconds

Currently we created datetime and timedelta objects to enforce the
rate limit. When the rate limit was being hit hard, this got expensive.

We now use floats everywhere instead as they are much cheaper which
is important when we are running up against a rate limit, which is
by definition a hot path

The rate limit helper is currently only used for templates and
we do not have any code in the code base that directly passes
in a rate limit so the impact to custom components is expected
to be negligible if any

* misesd two
2024-03-20 19:49:37 -04:00
Erik Montnemery 426f73b1f4
Add State.last_reported (#113511)
* Add State.last_reported

* Update tests

* Update test snapshots

* Call state_reported listeners when firing state_changed event

* Add tests
2024-03-20 21:05:07 +01:00