Commit graph

314 commits

Author SHA1 Message Date
karwosts
b471b9926d
Missing template helper translation keys (#109347) 2024-02-02 08:58:03 +01:00
RoboMagus
c54b65fdf0
Add 'last_reset' for 'total' state_class template sensor (#100806)
* Add last_reset to trigger based template sensors

* Add last_reset to state based template sensors

* CI check fixes

* Add pytests

* Add test cases for last_reset datetime parsing

* Add test for static last_reset value

* Fix ruff-format
2024-01-25 11:12:03 +01:00
J. Nick Koston
1cdfb06d77
Add cached_property to State.name (#108011) 2024-01-14 11:50:40 +01:00
J. Nick Koston
4b7a313ece
Use identity checks for CoreState (#107846)
Some of the checks used ==, and some used is. Switch
everything to is as its faster
2024-01-12 10:21:26 +01:00
Erik Montnemery
3a744d374b
Add support for caching entity properties (#100601) 2023-12-22 09:02:55 -10:00
Erik Montnemery
dd5a48996a
Keep capabilities up to date in the entity registry (#101748)
* Keep capabilities up to date in the entity registry

* Warn if entities update their capabilities very often

* Fix updating of device class

* Stop tracking capability updates once flooding is logged

* Only sync registry if state changed

* Improve test

* Revert "Only sync registry if state changed"

This reverts commit 1c52571596c06444df234d4b088242b494b630f2.

* Avoid calculating device class twice

* Address review comments

* Revert using dataclass

* Fix unintended revert

* Add helper method
2023-12-13 17:27:26 +01:00
Jan Bouwhuis
953a212dd6
Use ServiceValidationError for invalid fan preset_mode and move check to fan entity component (#104560)
* Use ServiceValidationError for fan preset_mode

* Use _valid_preset_mode_or_raise to raise

* Move preset_mode validation to entity component

* Fix bond fan and comments

* Fixes baf, fjaraskupan and template

* More integration adjustments

* Add custom components mock and test code

* Make NotValidPresetModeError subclass

* Update homeassistant/components/fan/strings.json

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

* Keep bond has_action validation

* Move demo test asserts outside context block

* Follow up comment

* Update homeassistant/components/fan/strings.json

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Fix demo tests

* Remove pylint disable

* Remove unreachable code

* Update homeassistant/components/fan/__init__.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Use NotValidPresetModeError, Final methods

* Address comments

* Correct docst

* Follow up comments

* Update homeassistant/components/fan/__init__.py

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

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-11-29 13:56:51 +01:00
Aarni Koskela
706add4a57
Switch formatting from black to ruff-format (#102893)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:38:59 +01:00
Jan Bouwhuis
9962301b42
Do not notify config errors during logging (#104466) 2023-11-24 21:34:09 +01:00
Jan Bouwhuis
af71c2bb45
Raise and suppress stack trace when reloading yaml fails (#102410)
* Allow async_integration_yaml_config to raise

* Docstr - split check

* Implement as wrapper, return dataclass

* Fix setup error handling

* Fix reload test mock

* Move log_messages to error handler

* Remove unreachable code

* Remove config test helper

* Refactor and ensure notifications during setup

* Remove redundat error, adjust tests notifications

* Fix patch

* Apply suggestions from code review

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

* Follow up comments

* Add call_back decorator

* Split long lines

* Update exception abbreviations

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-11-24 17:34:45 +01:00
Vaarlion
3929b0163c
Add RGB, RGBW and RGBWW capability to template.light (#86047)
* Add RGB, RGBW and RGBWW capability to template.light

Add the required unit test

Mute 'LightTemplate.async_turn_on' is too complex

Rename all HS color mode from a generic "Color" name to a specific "HS" name

* Bring back legacy "color" keyword

* Cleanup unrequested commented test

* Increase code coverage to 100%

* Remove confusing if that should never be false

* Apply suggestions from code review

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-11-22 08:15:26 +01:00
Erik Montnemery
5b37096b5f
Refactor config.async_log_exception (#104034)
* Refactor config.async_log_exception

* Improve test coverage

* Make functions public
2023-11-15 19:09:49 +01:00
Robert Resch
bb90c1f168
Fix multilevel reference translations (#102338) 2023-10-20 08:12:53 +02:00
Robert Resch
eab4c24f7f
Fix KeyError in derivative and integration (#102294) 2023-10-19 18:22:22 +02:00
Robert Resch
1a7601ebbe
Remove NONE_SENTINEL in favor of optional select in template (#101279) 2023-10-11 13:04:40 +02:00
G Johansson
43954d660b
Add trigger weather template (#100824)
* Add trigger weather template

* Add tests

* mod dataclass

* Remove legacy forecast

* Fix test failure

* sorting

* add hourly test

* Add tests

* Add and fix tests

* Improve tests

---------

Co-authored-by: Erik <erik@montnemery.com>
2023-09-27 10:11:57 +02:00
G Johansson
173b70c850
Fix weather template forecast attributes (#100748) 2023-09-23 13:30:11 +02:00
Erik Montnemery
d1afcd773f
Revert "Cache entity properties that are never expected to change in the base class" (#100422)
Revert "Cache entity properties that are never expected to change in the base class (#95315)"

This reverts commit 042776ebb8.
2023-09-15 11:25:24 +02:00
J. Nick Koston
042776ebb8
Cache entity properties that are never expected to change in the base class (#95315) 2023-09-14 17:48:48 -05:00
Jan Bouwhuis
0d33cba823
Use shorthand attrs in template integration (#100301) 2023-09-13 12:30:43 -05:00
Erik Montnemery
42046a3ce2
Fix TriggerEntity.async_added_to_hass (#100119) 2023-09-11 14:33:43 +02:00
Erik Montnemery
c9a6ea94a7
Send template render errors to template helper preview (#99716) 2023-09-06 16:07:05 +02:00
Erik Montnemery
e1ea53e72f
Correct state attributes in template helper preview (#99722) 2023-09-06 16:06:33 +02:00
Erik Montnemery
c376447ccd
Don't allow changing device class in template binary sensor options (#99720) 2023-09-06 15:59:30 +02:00
Erik Montnemery
cdca4591a4
Include template listener info in template preview (#99669) 2023-09-06 09:49:42 +02:00
Jan-Philipp Benecke
b28fda2433
Move template coordinator to its own file (#99419)
* Move template update coordinator to its own file

* Add coordinator.py to .coveragerc

* Remove coordinator.py to .coveragerc

* Apply suggestions from code review

* Update homeassistant/components/template/coordinator.py

* Copy over fixes from upstream

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
2023-09-06 08:54:25 +02:00
G Johansson
47c20495bd
Fix not stripping no device class in template helper binary sensor (#99640)
Strip none template helper binary sensor
2023-09-04 22:46:19 +02:00
Erik Montnemery
7c595ee2da
Validate state in template helper preview (#99455)
* Validate state in template helper preview

* Deduplicate state validation
2023-09-04 14:10:43 +02:00
Allen Porter
7b1c0c2df2
Extend template entities with a script section (#96175)
* Extend template entities with a script section

This allows making a trigger entity that triggers a few times a day,
and allows collecting data from a service resopnse which can be
fed into a template entity.

The current alternatives are to publish and subscribe to events or to
store data in input entities.

* Make variables set in actions accessible to templates

* Format code

---------

Co-authored-by: Erik <erik@montnemery.com>
2023-09-02 16:19:45 -07:00
Erik Montnemery
390c046537
Fix template helper strings (#99456) 2023-09-01 17:14:42 +02:00
Erik Montnemery
f36a300651
Improve template sensor config flow validation (#99373) 2023-08-31 15:16:32 +02:00
Erik Montnemery
501d5db375
Add config flow for template binary sensor (#99339) 2023-08-30 17:28:56 +02:00
Erik Montnemery
63c538b024
Add config flow for template sensor (#98970)
* Add config flow for template sensor

* Tweak error reporting

* Improve validation

* Fix test

* Rename translation strings

* Improve validation

* Fix sensor async_setup_entry

* Avoid duplicating sensor device class translations

* Avoid duplicating sensor device class translations

* Add config flow tests

* Include all units from DEVICE_CLASS_UNITS in unit_of_measurement select

* Address review comments
2023-08-30 16:22:52 +02:00
G Johansson
61c17291fb
Move TemplateEntity to template (#98957)
* Move TemplateEntity to template

* Rename template_entity in helpers
2023-08-24 15:37:04 +02:00
G Johansson
b69e8fda77
Remove TemplateSensor from the template_entity helper (#98945)
Clean off TemplateSensor
2023-08-24 12:14:39 +02:00
Ville Skyttä
b51c0f6ddc
Remove unnnecessary pylint configs from components [s-z]* (#98925) 2023-08-24 01:25:32 +02:00
G Johansson
207e3f90a6
Modernize template weather (#98064)
* Modernize template weather

* mods

* adds templates

* Fixes

* review comments

* more comments

* Fix validator

* Tests

* Mods

* Fix ruff
2023-08-21 15:48:14 +02:00
Ville Skyttä
3094991236
Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00
Franck Nijhof
868a5f377f
Ruff: isort don't split imports based on trailing comma (#98162) 2023-08-10 14:27:03 +02:00
Marc Mueller
582499a260
Improve async_track_template_result callback typing (#97135) 2023-07-24 12:42:17 +02:00
Marc Mueller
77f38e33e5
Import names from typing instead of typing_extensions [3.11] (#97065) 2023-07-22 17:03:44 -05:00
Joost Lekkerkerker
b367c95c81
Add more common translations (#96429)
* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations

* Add common translations
2023-07-12 22:00:05 -04:00
Franck Nijhof
c3871cc5ae
Migrate template services to support translations (#96414) 2023-07-12 14:06:14 +02:00
Erik Montnemery
b8af7fbd55
Update template vacuum supported features (#95831) 2023-07-08 11:47:49 +02:00
Erik Montnemery
68db751ce1
Refactor template image (#95353) 2023-06-27 18:46:36 +02:00
G Johansson
30d22fe49b
Add new attributes into Template Weather (#95100) 2023-06-27 11:19:51 +02:00
Jan Bouwhuis
98cc45ec10
Add image url support (#95301)
* Add image url support

* Use hass as parameter

* Add verify ssl parameter and improve exception handling

* Improve error handling, ignore empty URL's

* Update existing image platforms

---------

Co-authored-by: Erik <erik@montnemery.com>
2023-06-27 08:36:12 +02: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
3e71b1daa4
Correct calls to super class in TriggerEntity (#94916) 2023-06-20 23:00:22 +02:00
G Johansson
1fa82fa886
Move TriggerBaseEntity into helpers (#91945)
* Move TriggerBaseEntity

* mypy
2023-04-25 09:56:40 +02:00