Commit Graph

326 Commits

Author SHA1 Message Date
Petro31
5048d1512c Add trigger based template cover (#145455)
* Add trigger based template cover

* address comments

* update position template in test
2025-05-23 16:32:21 +02:00
Petro31
752c73a2ed Add trigger_variables to template trigger 'for' field (#136672)
* Add trigger_variables to template trigger for

* address comments
2025-05-19 17:26:42 +02:00
Petro31
3bf9908789 Add template vacuum modern style (#144843)
* Add template vacuum modern style

* address comments and add tests for coverage

* address comments

* update vacuum and sort domains
2025-05-15 15:46:00 +02:00
Petro31
66ecc4d69d Add modern configuration for template alarm control panel (#144834)
* Add modern configuration for template alarm control panel

* address comments and add tests for coverage

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2025-05-15 11:46:57 +02:00
Petro31
ea046f32be Add modern style template lock (#144756)
* Add modern style lock

* add tests

* Add tests and address comments

* Update homeassistant/components/template/lock.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2025-05-15 10:43:56 +02:00
Petro31
c7cf9585ae Add modern style configuration for template fan (#144751)
* add modern template fan

* address comments and add tests for coverage
2025-05-15 08:18:37 +02:00
Erik Montnemery
40217e764d Allow overriding blueprinted templates (#143874)
* Allow overriding blueprinted templates

* Remove duplicated line
2025-04-30 12:14:28 +02:00
Petro31
95552e9a5b Add trigger based template lights (#140631)
* Add abstract template light class in preparation for trigger based template lights

* add base for trigger entity

* Update more tests

* revert trigger template entity changes and light trigger tests.

* fix merge conflicts

* address comments

* change function name

* nitpick

* fix merge conflict issue

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2025-04-29 18:02:44 +02:00
chammp
8ff4d5dcbf Adapt template sensors to use the same plural trigger/condition/action definitions as automations (#127875)
* Add plurals to template entities

* Ruff

* Ruffy ruff

* Fix linters

* Fix bug introduced after merging dev

* Fix merge mistake

* Revert adding automation helper

* Revert "Fix bug introduced after merging dev"

This reverts commit 098d478f150a06546fb9ec3668865fa5d763c6b2.

* Fix blueprint validation

* Apply suggestions from code review

---------

Co-authored-by: Erik <erik@montnemery.com>
2025-04-29 11:52:58 +02:00
Petro31
b2fcab20a6 Add trigger based entities to template switch (#141763)
* Add trigger based entities to template switch platform

* add suggestions
2025-04-29 09:40:16 +02:00
Petro31
469176c59b Fix trigger template entity issue when coordinator data is None (#143830)
Fix issue when coordinator data is None
2025-04-28 14:32:16 +02:00
Petro31
4a1905a2a2 Update template cover to modern style config (#141878) 2025-04-25 15:22:49 +02:00
Petro31
ff2c901930 Update trigger based template entity resolution order (#140660)
* Update trigger based template entity resolution order

* add test

* fix most comments

* Move resolution to base class

* add comment

* remove uncessary if statement

* add more tests

* update availability tests

* update logic stage 1

* phase 2 changes

* fix trigger template entity tests

* fix trigger template entities

* command line tests

* sql tests

* scrape test

* update doc string

* add rest tests

* update sql sensor _update signature

* fix scrape test constructor

* move state check to trigger_entity

* fix comments

* Update homeassistant/components/template/trigger_entity.py

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

* Update homeassistant/helpers/trigger_template_entity.py

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

* Update homeassistant/helpers/trigger_template_entity.py

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

* update command_line and rest

* update scrape

* update sql

* add case to command_line sensor

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2025-04-25 13:17:25 +02:00
epenet
a3605921c9 De-duplicate test helper function (#143437)
* De-duplicate test helper function

* One more
2025-04-22 12:04:12 +02:00
Petro31
9b274a0bc4 Correct template fan optimistic mode and supported features (#142414) 2025-04-14 15:40:29 +02:00
Petro31
8d95fb3b31 Fix empty actions (#142292)
* Apply fix

* Add tests for alarm button cover lock

* update light

* add number tests

* test select

* add switch tests

* test vacuum

* update lock test
2025-04-04 22:17:52 +02:00
Petro31
36857b4b20 Fix weather templates using new style configuration (#136677) 2025-04-02 12:38:48 +02:00
Petro31
31479056ed Fix an issue with the switch preview in beta (#141617)
Fix an issue with the switch preview
2025-03-28 00:43:17 +02:00
Petro31
212d39ba19 Migrate template switch to new style (#140324)
* Migrate template switch to new style

* update tests

* Update tests

* Add config flow migration

* comment fixes

* revert entity config migration
2025-03-20 15:12:43 +01:00
Petro31
84667fd32d Migrate template light to new style (#140326)
* Migrate template light to new style

* add modern templates to tests

* fix comments
2025-03-14 09:00:46 +01:00
Petro31
293d455cba Add check for invalid options with specific platforms (#140082) 2025-03-08 00:09:04 +01:00
Petro31
aec6868af1 Add abstract class to trigger based template entities (#139650)
* add abstract class to trigger based template entities

* updates after merge of parent PR

* add comments

* add tests
2025-03-06 08:00:11 +01:00
Petro31
890d3f4af4 Add a base class for template entities to inherit from (#139645)
* add-abstract-template-entity-base-class

* review 1 changes
2025-03-04 07:23:05 +01:00
Jan Bouwhuis
fdf69fcd7d Improve calculating supported features in template light (#139339) 2025-02-26 15:09:20 +00:00
Erik Montnemery
428cc1a951 Update signature of platforms' async_setup_entry in tests (#138271) 2025-02-11 13:17:39 +01:00
epenet
d0a188b86d Standardize homeassistant imports in component tests (m-z) (#136807) 2025-01-29 08:57:57 +01:00
Petro31
d06b0fe340 Reload template blueprints when reloading templates (#136794) 2025-01-28 22:48:38 -05:00
epenet
b11b36b523 Add more util aliases to import conventions (#136153) 2025-01-21 15:58:23 +01:00
Stefan Agner
9ab69aa41c Add mWh as unit of measurement for Matter energy sensors (#133005) 2024-12-13 09:33:58 +01:00
epenet
7bdf034b93 Migrate template light tests to use Kelvin (#133025) 2024-12-12 13:54:22 +01:00
G Johansson
2eaf206562 Implement new state property for vacuum which is using an enum (#126353)
* Implement new state property for vacuum which is using an enum

* Mod

* Mod init

* Mods

* Fix integrations

* Tests

* Fix state

* Add vacuum tests

* Fix last test

* Litterrobot tests

* Fixes

* Tests

* Fixes

* Fix VacuumEntity

* Mods

* Mods

* Mods

* Update demo

* LG

* Fix vacuum

* Fix Matter

* Fix deprecation version

* Mods

* Fixes

* Fix ruff

* Fix tests

* Fix roomba

* Fix breaking dates
2024-12-06 11:16:03 +01:00
G Johansson
3464ffc53e Add open to Template lock (#129292)
* Add open to Template lock

* Update from review
2024-11-27 13:26:57 +01:00
Martin Hjelmare
ccbbcbb264 Make set value template number option required (#131625) 2024-11-26 19:27:59 +01:00
Sid
9e98e446a2 Bump ruff to 0.8.0 (#131273) 2024-11-22 16:53:26 +01:00
G Johansson
d0ad834d93 Move manual trigger entity tests (#130134) 2024-11-10 12:14:13 +01:00
Jakob Schlyter
cd11f01ace Add support for MW/GW/TW and GWh/TWh (#130089) 2024-11-08 22:12:16 +01:00
Paulus Schoutsen
a927312fb5 Ensure all template names are strings (#129921) 2024-11-05 22:36:26 -05:00
G Johansson
cdfec7ebb4 Implement new state property for alarm_control_panel which is using an enum (#126283)
* Alarm state from enum

* Fixes

* Set final

* Fix rebase

* Test const

* Fix breaking version

* Fix other for alarm_control_panel

* Fix integrations

* More

* More

* More

* More

* Fix zha

* Replace _attr_state

* Fix alarm_control_panel

* Fix tests

* Fixes

* Mods

* Change some

* More

* More

* More

* Tests

* Last tests

* Return enum

* Fix zha

* Remove not needed check

* Fix wording

* Fix homekit

* Mod prometheus

* Fix mypy

* Fix homekit

* Fix ifttt
2024-10-21 22:54:27 +02:00
epenet
838519e89f Use STATE_ON/STATE_OFF constants in template test (#128883) 2024-10-21 16:19:44 +02:00
epenet
be4641b8f3 Push real binary sensor states to state machine in tests (#128894) 2024-10-21 16:19:25 +02:00
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