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
Add availability_template option to all template platforms #25891
Conversation
Hey there @PhracturedBlue, mind taking a look at this pull request as its been labeled with a integration ( |
Please, update the documentation and open a PR for it (be sure to create a documentation PR against the 🏷 I am adding the |
home-assistant.io document PR added (Sorry. chicken/egg problem ;-) ) |
Please note that in your code, the state of the sensors is considered available until the first update. This may cause a malfunction. It’s more correct to consider the state unavailable until the first update, because it is not yet defined. It will also be more correct to always give None for state when the state is unavailable. You have not done this. |
Hey @Limych,
Do you mean that the
Not sure I agree. By just having I also am not sure about my implementation where I check for a string result of
Thoughts? |
There are merge conflicts. |
This PR should be broken up in 1 PR per platform. it is too big as is. |
That's what happens when a PR stays open for 20+ days! Fixing now. |
@balloob , It is the same feature 'availability_template' feature added to all template platform components, so I think they all belong together. And each change to a component source is discreet/isolated and has an associated test file change. Also all require the same change to Cheers G./ |
Please break it up and start with one platform. |
Breaking Change:
Not a Breaking change
Description:
This PR adds an
availability_template
option to each component in the Template Platform.By defining the
availability_template
theavailability
of a template component can be controlled using a template.As Template Components rely on other component states, (i.e. they do not have state themselves) it would be useful to also be able to control when a component is unavailable. e.g. when a component that the template component relies on to function becomes 'unavailable it would be useful to be able to mark the template component as 'unavailable also.
If the
availability_template
is not configured, the device will always be 'available' (default behavior)If the
availability_template
is configured, the device will be 'available' if the template returnstrue
or 'unavailable' if the template returns any other value.home-assistant/home-assistant.io#10123
Example entry for
configuration.yaml
(if applicable):For a Cover Template component that requires a 'switch.garage_clicker' to be available to operate:
Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
python3 -m script.hassfest
.requirements_all.txt
by runningpython3 -m script.gen_requirements_all
..coveragerc
.If the code does not interact with devices: