Help with Irrigation factor for rain and temperature #111
-
Hey, sorry @patfelst. Hope this is the right way to do it. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Yes I believe it is. I’ll answer tomorrow. |
Beta Was this translation helpful? Give feedback.
-
@petergridge could you maybe assist? Also how does the frequency for temperature work exactly? How do I configure the script to match my needs? |
Beta Was this translation helpful? Give feedback.
-
So you need to learn how to use home assistant jinja templates. You can experiment in home assistant's template editor, you'll find it under developer tools. Here's a complete example you can paste into the template editor. It's showing how you could use the temperature history (max temperature of each day) for the last 4 days and also today (day0max). It outputs a single floating point number which is the adjustment factor. You can use any function you can dream up here. I just asked chatgpt to write a function and this is what it came up with. {% set day0max = 35 %}
{% set day1max = 30 %}
{% set day2max = 26 %}
{% set day3max = 25 %}
{% set day4max = 18 %}
{% set temp_base = 24 %}
{% set temp_slope = 0.04 %}
{% set weighted_temp = (
day0max +
(day1max * 0.5) +
(day2max * 0.25) +
(day3max * 0.12) +
(day4max * 0.06)
) / (1 + 0.5 + 0.25 + 0.12 + 0.06) %}
{% set temp_factor = 1 + ((weighted_temp - temp_base) * temp_slope) %}
{# ===== IF/THEN CLAMP ===== #}
{% if temp_factor < 0 %}
{% set clamped_factor = 0 %}
{% elif temp_factor > 2 %}
{% set clamped_factor = 2 %}
{% else %}
{% set clamped_factor = temp_factor %}
{% endif %}
{{ clamped_factor | float }} You should see the result of 1.34 in the template editor. The first five lines {% set day0max = states('sensor.owmh_home_day0max') | float %}
{% set day1max = states('sensor.owmh_home_day1max') | float %} etc Once you're happy with the template, create a new sensor in OWMH, and paste it in, exept of course don't include the first 5 lines as they are internally generated by OWMH. |
Beta Was this translation helpful? Give feedback.
So you need to learn how to use home assistant jinja templates. You can experiment in home assistant's template editor, you'll find it under developer tools.
Here's a complete example you can paste into the template editor. It's showing how you could use the temperature history (max temperature of each day) for the last 4 days and also today (day0max). It outputs a single floating point number which is the adjustment factor. You can use any function you can dream up here. I just asked chatgpt to write a function and this is what it came up with.