-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update trigger based template entity resolution order #140660
base: dev
Are you sure you want to change the base?
Update trigger based template entity resolution order #140660
Conversation
Hey there @PhracturedBlue, @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Please improve the breaking change section, it should explain what has changed (what's the new behavior, and what was the behavior in the previous release) and how it may break things |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this fixed in TriggerEntity
instead of in TriggerBaseEntity
, do other classes derived from TriggerBaseEntity
never have availability templates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to impact all the other integrations that use ManualTriggerEntity which inherits from TriggerBaseEntity. I can investigate how this change will impact those integrations if need be.
return render_complex(self._config[key], variables) | ||
|
||
return self._config[key].async_render( | ||
variables, parse_result=key in self._parse_result, strict=strict | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these also return _SENTINEL
or can that only happen below after we caught an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can only happen after we caught an error. This is so that the templates can render None. Originally I was only using none as the return, however that caused issues across the board because None
means unknown
for trigger based entities. I was forced to use _SENTINEL to allow None as a returned result.
) is not _SENTINEL: | ||
rendered[key] = result | ||
|
||
for key in self._to_render_complex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't availability or state templates be complex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I can tell. The original method only treats them as non-complex renders. I assumed this is because they only render a string or true/false and they won't render any complex objects like a dictionary or list.
There are differences between trigger based template entities and normal template entities.
Resolution order
Resolution exception handling
Breaking change
Proposed change
Trigger based template entities will behave the same way as template entities.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: