2jan
May 15, 2019, 8:54pm
1
Is it possible to include the min and max values set in config of the plant component into the plant state as attributes? The reason for doing this is that I want to be able to create automations and notifications based on e.g. the minimum moisture or brightness (eg turn on water or light) without having to define min and max levels more than one place, ie in the plant config. Would be very convenient when having several sensors.
I know basic Python, but after looking at the code I see this is a few levels up from my competence level.
Plant component: https://www.home-assistant.io/components/plant/
I guess I would like to have them reported in the list by the red arrow when looking at the plant state:
From your link:
It also supports setting minimum and maximum values for each measurement and will change its state to “problem” if it is not within those limits.
Is that what you want? You could then trigger off that.
2jan
May 18, 2019, 8:55pm
3
I have set minimum and maximum for every measurement. Now I want to read those min and max values…
Grzech
(Grzech)
May 29, 2019, 8:22am
4
Did you ask about something like this?
I built it using the button-card:
https://github.com/custom-cards/button-card
1 Like
2jan
May 29, 2019, 8:22pm
5
I am not looking for a Lovelace-card per se, but you may nevertheless have solved what I am looking for since you probably are using the values I am looking for if you are populating them from the plant component. Could you please share the code for this?
2jan
July 2, 2019, 10:55am
6
So no one knows how to access the plant attributes?
2jan
July 9, 2019, 8:35pm
7
I think this may clarify the issue a bit:
{{ state_attr('plant.107', 'moisture') }}
will give the current moisture level for a specific plant (named 107 in this case). What I would like to get hold of is also something like {{ state_attr('plant.107', 'min_moisture') }}
and {{ state_attr('plant.107', 'max_moisture') }}
for the same plant, but these attributes are not present in the plant.107 entity today…
1 Like
@2jan I’m also looking for additional attributes to the plant entity like you have proposed which would have allowed more fine-grained automatons than what the problem
attribute can achieve.
1 Like
Sand
May 1, 2022, 2:38pm
9
I only see this post now but yesterday I added the min_moisture attribute in my custom version of plant component. No idea if this is good coding practice but it works.
ATTR_CONF_MIN_MOISTURE = "conf_min_moisture"
…
def __init__(self, name, config):
self._min_moisture_conf = self._config[CONF_MIN_MOISTURE]
…
…
def extra_state_attributes(self):
attrib = {
ATTR_PROBLEM: self._problems,
ATTR_SENSORS: self._readingmap,
ATTR_CONF_MIN_MOISTURE: self._min_moisture_conf,
ATTR_DICT_OF_UNITS_OF_MEASUREMENT: self._unit_of_measurement,
}
Ref.: Add max/min-configuration to Plant-attributes
1 Like
@Sand , How to create a custom version of plant component? Which all files need to be modified? Will these alterations be lost with HomeAssistant updates?
Sand
May 1, 2022, 9:53pm
11
You just put the components files into a custom_components folder and edit them there.
1 Like
@Sand , so what happens to the original component? Do I need to remove it? Will it be over-ridden automatically by the <config>/custom_components/plant
Have anybody submitted a pull request with these changes to the original repository?
Sand
May 2, 2022, 1:22pm
13
The custom component will have priority over the built in one. It will not change on HA updates. If you remove it, the built in one will be used again.
I don’t know about pull requests but I found this: Min/Max values on Plant integration not populated as attributes · Issue #70583 · home-assistant/core · GitHub
1 Like
2jan
June 1, 2022, 7:52pm
14
There is an active Pull Request on this matter now
home-assistant:dev
← greghesp:feat/plant-attributes
opened 07:28AM - 08 May 22 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue in the
additional information section.
-->
Fixes https://github.com/home-assistant/core/issues/70583
The min/max values that the `plant` component uses to make calculations are not exposed as attributes. This causes problems for custom cards such as the [Lovelace Flower Card](https://github.com/Olen/lovelace-flower-card), as users must used a [patched version](https://github.com/Olen/homeassistant-plant) of this component.
This change exposes those values under the `limits` section within the attributes.
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes Fixes https://github.com/home-assistant/core/issues/70583
- Please let me know if i've missed anything, or if there are any improvements. I'm not great at Python, so may have missed some core concept.
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [x] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] The code has been formatted using Black (`black --fast homeassistant tests`)
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.
Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.
Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to `.coveragerc`.
The integration reached or maintains the following [Integration Quality Scale][quality-scale]:
<!--
The Integration Quality Scale scores an integration on the code quality
and user experience. Each level of the quality scale consists of a list
of requirements. We highly recommend getting your integration scored!
-->
- [ ] No score or internal
- [ ] 🥈 Silver
- [ ] 🥇 Gold
- [ ] 🏆 Platinum
<!--
This project is very active and we have a high turnover of pull requests.
Unfortunately, the number of incoming pull requests is higher than what our
reviewers can review and merge so there is a long backlog of pull requests
waiting for review. You can help here!
By reviewing another pull request, you will help raise the code quality of
that pull request and the final review will be faster. This way the general
pace of pull request reviews will go up and your wait time will go down.
When picking a pull request to review, try to choose one that hasn't yet
been reviewed.
Thanks for helping out!
-->
To help with the load of incoming pull requests:
- [ ] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/en/development_checklist.html
[manifest-docs]: https://developers.home-assistant.io/docs/en/creating_integration_manifest.html
[quality-scale]: https://developers.home-assistant.io/docs/en/next/integration_quality_scale_index.html
[docs-repository]: https://github.com/home-assistant/home-assistant.io