jeroenterheerdt / HAsmartirrigation

Smart Irrigation custom component for Home Assistant
https://jeroenterheerdt.github.io/HAsmartirrigation/
MIT License
367 stars 49 forks source link

In case of daily precipitation level is more than soil can hold #110

Closed andreid1303 closed 1 year ago

andreid1303 commented 2 years ago

I have grass on sandy soil that saturated fully with precipitation level about 12 mm (according trusted soil moisture sensor), so excess of the water just goes bellow the root depth and will not be available for plants. Thus we need to subtract the excess from the bucket in case daily precipitation rate is more than 12 mm/day, right? Really, we have enormous rain 60 mm in a day two weeks ago and since that the bucket is still 20 mm without reset but the soil dried out after 6 days. I think an addition of optional entry and automatic correction of bucket can be easily implemented.

Andrew-Joakimsen commented 1 year ago

In my installation I've created a virtual sensor to handle this condition:

template:
  - name: "Irrigation Daily Rain Rate"
    unique_id: 98038f04-720b-11ed-a1eb-0242ac120002
    state_class: total
    unit_of_measurement: in
    state: >
      {% if state_attr('sensor.smart_irrigation_daily_adjusted_run_time', 'bucket') | int >= 1.2 and states('sensor.daily_rain_rate') | int >= 0.3  %}   
        0.3
      {% elif states('sensor.daily_rain_rate') | int >= 1.1 %}
        1.1
      {% elif states('sensor.daily_rain_rate') | int < 1.1 %}
        {{ states('sensor.daily_rain_rate') }}
      {% else %}
        unavailable
      {% endif %}
andreid1303 commented 1 year ago

Thank you, this is a solution, but not taken evapotranspiration loses of current day into account.

NathanSweet commented 1 year ago

Are you saying you want a max bucket size?

andreid1303 commented 1 year ago

Yes, max bucket size!

mcnelson commented 1 year ago

I just realized I have this issue too. After the rainy season, I'm finding my buckets are way too high, and now that we're in sunny weather the irrigation never runs. I have values like about 24.0 in the buckets and they are decreasing like 0.3 - 0.5 per day which is way too slow.

I could reset the buckets annually, but it would be nice if the script could resolve this on its own. At this rate I don't know if I'd see any irrigation until the middle of summer, which just seems incorrect. A maximum bucket value could help here? Perhaps my config is off?

bulburDE commented 1 year ago

I also stumbled across this problem since we had an unusual amount of rain in the last few days. I am trying to solve it with an automation that sets the bucket value to a threshold (20) if the bucket is set to an amount over the threshold.

alias: irrigation maximum rasen bucket
description: ""
trigger:
  - platform: event
    event_type: Smart_Irrigation_Rasen_bucketUpd
condition:
  - condition: numeric_state
    entity_id: sensor.smart_irrigation_rasen_daily_adjusted_run_time
    attribute: bucket
    above: 20
action:
  - service: smart_irrigation.smart_irrigation_rasen_set_bucket
    data:
      value: 20
mode: single

I just create it and tested it once so I can't say yet if it will work as expected.

jeroenterheerdt commented 1 year ago

interesting, a max bucket is absolutely something we can do.... in the 2.0 version which is now in beta. Actually, if someone would implement a calc module that implements a max value for duration it would achieve the same thing, but then directly right?

jeroenterheerdt commented 1 year ago

We now have maximum duration in the beta.

wauswaus commented 1 year ago

We now have maximum duration in the beta.

Could you explain how a max duration is the same as a max bucket (limiter)? When the bucket has a big positive value the calculated duration will be zero as there is no need for Irrigation. Therefore a max duration is not the same. Hence this ticket should not be closed. I also created automations as above to check if bucket is higher the a threshold. If so write threshold value as bucket value.

jeroenterheerdt commented 1 year ago

Why do you want a max limiter on bucket? It does not have any impact as as you said there is no irrigation. The max duration is more of a large negative bucket value limiter. I think adding a large positive value limiter for bucket will be more confusing in the UI than adding value.

NathanSweet commented 1 year ago

The bucket represents the excess moisture that the soil is holding. There is a limit to how much moisture the soil can hold, therefore a max limit on the bucket is needed.

jeroenterheerdt commented 1 year ago

But why? We're not in the business of tracking soil moisture just for that. The purpose of this integration is to irrigate when needed. I fail to see why a max bucket is relevant. Anyhow, I can add it. What would be a good default? I assume you want to apply the max bucket when the bucket is updated and is above the max bucket value?

wauswaus commented 1 year ago

I live in in an area where there is sandy soil. This means rain is passed to lower soil layers quite easily. Consider the following example. We start with a bucket value of 0mm.It rains for 10 days, 8mm each day. Bucket value after this time is 80mm. In my sandy soil maybe 75% of this water already seaped into lower layers. The weather turns, lots of sun and an evaporation transpiration rate of 4mm a day. With a start bucket value of 80mm the Irrigation would kick in after 80/4 = 20 days. When that would happen I would already have plants dying because top layer is bone dry. That's why I limit the bucket value to a max value. I hope this clarifies it some more.

Your proposal is exactly what we made in home assistant automations. When bucket value is updated and is above a max, the max value is applied to the bucket value. If you could add this to the integration that would be great!

NathanSweet commented 1 year ago

But why? We're not in the business of tracking soil moisture just for that.

We really are, though: we track the surplus or deficit of moisture in the soil. When there is a deficit, we irrigate. When there is a surplus, we do nothing, letting the evapotranspiration calculation reduce the surplus over time. There is a limit to the moisture soil can hold, called "field capacity". Any further moisture added will drain away. If we don't limit the "bucket" (aka "water balance") then the calculations will think there is an enormous surplus that isn't physically possible and we will erroneously skip irrigation for a long time.

The field capacity varies a lot by the type of soil, so the bucket "size" needs to be configurable. For example, loam (a mixture of clay, sand, silt) can have 20-30% field capacity by volume. For that to be meaningful, you need to determine the depth of the soil that you care about. That can depend on what you are growing, but for example for Zoysia grass it could be 6-7" or 150-178mm. Multiply by the field capacity to get the bucket size, eg: 160mm * 25% = 40mm.

I'm a noob and it would be good to get confirmation of all this from those with more experience, but the above is my understanding.

jeroenterheerdt commented 1 year ago

Added this capability in beta 8. Closing this now. Please open an issue if you find anything wrong with the implementation. Thanks all!