6bb4e7d62c
Bump ruff to 0.3.4 ( #112690 )
...
Co-authored-by: Sid <[email protected] >
Co-authored-by: Marc Mueller <[email protected] >
Co-authored-by: J. Nick Koston <[email protected] >
2024-03-26 00:02:16 +01:00
J. Nick Koston and GitHub
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
J. Nick Koston and GitHub
6b5518b2bf
Fix template sensor test relying on event bus debug logging ( #113842 )
2024-03-19 10:44:04 -10:00
d0352ed91d
Fix missing context when running script from template entity ( #113523 )
...
Co-authored-by: J. Nick Koston <[email protected] >
2024-03-16 12:37:24 -10:00
Marc Mueller and GitHub
87165c0d6e
Add empty line after module docstring [tests t-z] ( #112712 )
2024-03-08 14:44:56 +01:00
RoboMagus and GitHub
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 and GitHub
c399cab427
Small speed up to checking core state ( #107845 )
2024-01-18 08:41:32 -10:00
J. Nick Koston and GitHub
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 and GitHub
42046a3ce2
Fix TriggerEntity.async_added_to_hass ( #100119 )
2023-09-11 14:33:43 +02:00
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 <[email protected] >
2023-09-02 16:19:45 -07:00
Erik Montnemery and GitHub
8c04e4c7a3
Add explicit test of template config entry setup ( #99345 )
2023-08-30 19:56:34 +02:00
Erik Montnemery and GitHub
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
epenet and GitHub
9762b684c2
Adjust entity registry access in tests (3) ( #88964 )
2023-03-01 16:04:40 +01:00
epenet and GitHub
88cfbf6a34
Add type hints to integration tests (part 22) ( #88234 )
2023-02-16 14:08:03 +01:00
Franck Nijhof and GitHub
d3ed8de232
Update Ruff to v0.0.247 ( #88210 )
...
* Update Ruff to v0.0.247
* Fix new found violations
2023-02-15 16:46:03 -05:00
Franck Nijhof and GitHub
ed79265843
Enable Ruff PT006 ( #88165 )
...
* Enable Ruff PT006
* Adjust existing cases
* Fix tests
* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet and GitHub
278050a73f
Add type hints to integration tests (t-z) ( #87707 )
2023-02-08 19:10:53 +01:00
epenet and GitHub
1a8933d59d
Adjust invalid test values in template ( #86008 )
2023-01-16 14:42:47 +01:00
Franck Nijhof and GitHub
2e92fefc0a
Fix uom/device class mismatches in tests ( #84372 )
2022-12-21 22:47:59 +01:00
akloeckner and GitHub
aa314a0901
Add this variable to trigger-based templates ( #72437 )
...
add this variables to trigger-based templates
follow-up for https://github.com/home-assistant/core/issues/70359
2022-06-27 08:59:29 +02:00
Erik Montnemery and GitHub
eba125b093
Ensure 'this' variable is always defined for template entities ( #70911 )
2022-05-03 07:43:44 -07:00
Erik Montnemery and GitHub
9bec649323
Restore state of trigger-based template sensor ( #69344 )
2022-04-21 09:32:18 -07:00
d20a620590
Make this variable available in template entities ( #65201 )
...
* feat: make this variable available in template entities
This makes the variable `this` available in template entities.
It will simplify the use of self-referencing template entities.
Because, without this, we have to repeat the entity id every time.
If we can solve this without explicitly spelling the entity id,
code can be re-used much better.
As a side-effect, this will allow to use `variables`-like patterns,
where attributes can be used as variables to calculate subsequent attributes or state.
Example:
```yaml
template:
sensor:
- name: test
state: "{{ this.attributes.test }}"
# not: "{{ state_attr('sensor.test', 'test' }}"
attributes:
test: "{{ now() }}"
```
* expose entity_id instead of this
* add test
* Refactor to expose this variable
* Tweak repr dunder
Co-authored-by: Erik <[email protected] >
2022-04-20 15:30:17 +02:00
Franck Nijhof and GitHub
d645e80ccd
Clean up async_update_entity helper usage ( #68641 )
2022-03-25 15:22:58 -07:00
cf4033b1bc
Simplify time zone setting in tests ( #68330 )
...
* Simplify timezone setting in tests
* Fix typo
* Adjust caldav tests
* Adjust input_datetime tests
* Adjust time_date tests
* Adjust tod tests
* Adjust helper tests
* Adjust recorder tests
* Adjust risco tests
* Adjust aemet tests
* Adjust flux tests
* Adjust forecast_solar tests
* Revert unnecessary change in forecast_solar test
* Adjust climacell tests
* Adjust google tests
* Adjust sensor tests
* Adjust sonarr tests
* Adjust template tests
* Adjust zodiac tests
Co-authored-by: Martin Hjelmare <[email protected] >
2022-03-20 10:25:15 +01:00
1ed490ce62
Fix date/datetime support for templates ( #61088 )
...
Co-authored-by: Paulus Schoutsen <[email protected] >
2021-12-09 11:43:48 +01:00
Erik Montnemery and GitHub
c1d671b817
Fix template sensor when name template doesn't render ( #58088 )
2021-10-20 14:53:06 -07:00
a4d9019ffc
Refactor persistent notification to no longer route all data via a service ( #57157 )
...
* Convert persistent notification tests to async
* Create/dismiss persistent notifications in exposed functions, not service calls
* Fix notify persistent_notification
* Remove setting up persistent_notification
* Drop more setups
* Empty methods
* Undeprecate sync methods because too big task
* Fix setup clearing notifications
* Fix a bunch of tests
* Fix more tests
* Uno mas
* Test persistent notification events
* Clean up stale comment
Co-authored-by: Martin Hjelmare <[email protected] >
2021-10-07 12:58:00 +02:00
jan iversen and GitHub
6348bf70ac
Add caplog setup fixture. ( #55714 )
2021-09-04 07:09:55 -07:00
jan iversen and GitHub
7aa454231f
Update template/test_sensor.py to use pytest ( #55288 )
2021-09-03 22:56:12 -07:00
Paulus Schoutsen and GitHub
0c2772e0be
Fix template sensor availability ( #55635 )
2021-09-03 09:02:45 +02:00
Paulus Schoutsen and GitHub
cc00617cd5
Allow defining state class for template sensors ( #52130 )
2021-06-23 14:37:04 -07:00
Paulus Schoutsen and GitHub
dcee78b747
Template sensor/binary sensors without trigger now respect section unique id ( #49613 )
2021-04-24 07:14:31 -07:00
Paulus Schoutsen and GitHub
65126cec3e
Allow top level non-trigger template entities ( #48976 )
2021-04-12 17:15:50 -07:00
Paulus Schoutsen and GitHub
e882460933
Support modern config for the trigger based template entity ( #48635 )
2021-04-02 16:57:16 -07:00
Paulus Schoutsen and GitHub
212d9aa748
Fix trigger template entities without a unique ID ( #48631 )
2021-04-02 10:24:38 -07:00
022f56f54d
Allow specifying template entities based on triggers ( #48169 )
...
Co-authored-by: Martin Hjelmare <[email protected] >
2021-03-29 09:57:51 -07:00
Erik Montnemery and GitHub
ed31cc363b
Wait for registries to load at startup ( #46265 )
...
* Wait for registries to load at startup
* Don't decorate new functions with @bind_hass
* Fix typing errors in zwave_js
* Load registries in async_test_home_assistant
* Tweak
* Typo
* Tweak
* Explicitly silence mypy errors
* Fix tests
* Fix more tests
* Fix test
* Improve docstring
* Wait for registries to load
2021-02-11 17:36:19 +01:00
Franck Nijhof and GitHub
65cf2fcb6f
Drop asynctest ( #44746 )
2021-01-01 22:31:56 +01:00
J. Nick Koston and GitHub
935c2df7cb
Add a test for template entities that reuse the template ( #42404 )
2020-10-26 16:08:57 +01:00
ee914366a8
Add native Python types support to templates ( #41227 )
...
Co-authored-by: Paulus Schoutsen <[email protected] >
2020-10-07 00:05:52 +02:00
sycx2 and GitHub
e813d3ebf9
Improve template test sensor ( #41199 )
2020-10-05 14:52:31 +02:00
J. Nick Koston and GitHub
deedd41d62
Prevent template loop detection from triggering when all templates are self referencing ( #41013 )
2020-10-01 22:11:11 +02:00
J. Nick Koston and GitHub
b45215f1d2
Implement template rate_limit directive ( #40667 )
2020-10-01 21:39:44 +02:00
J. Nick Koston and GitHub
aaa8083d49
Change template loop detection strategy to allow self-referencing updates when there are multiple templates ( #39943 )
2020-09-12 14:20:21 +02:00
J. Nick Koston and GitHub
fd8a4182d9
Detect self-referencing loops in template entities and log a warning ( #39897 )
2020-09-10 20:50:11 +02:00
Franck Nijhof and GitHub
1c2ebdf307
Upgrade black to 20.8b1 ( #39287 )
2020-08-27 13:56:20 +02:00
J. Nick Koston and GitHub
20398cc0a6
Subscribe to state change events only if the template has entities ( #39188 )
2020-08-26 00:20:04 +02:00
J. Nick Koston and GitHub
83b9c6188d
Make template entities reloadable ( #39075 )
...
* Make template entities reloadable
* Address review items
2020-08-21 18:31:48 -05:00
1381b279f0
Update template sensor to use async_track_template_result ( #38940 )
...
* Add template entity
* Update template tracking to work for template sensors
* add test for whitespace
* Update homeassistant/helpers/config_validation.py
* revert
* fix
* reduce
* fix _refresh missing decorator
* defer until start
* do not throw errors during startup
* defer tracking until start event
Co-authored-by: Swamp-Ig <[email protected] >
2020-08-20 08:06:41 -05:00