Plant component: Include max and min values to the plant state attributes

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.

I have set minimum and maximum for every measurement. Now I want to read those min and max values…

Did you ask about something like this?


I built it using the button-card:
https://github.com/custom-cards/button-card

1 Like

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?

So no one knows how to access the plant attributes?

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

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?

You just put the components files into a custom_components folder and edit them there.

image

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?

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

There is an active Pull Request on this matter now :slight_smile: