Open ekkesa opened 3 years ago
@kloggy This ain't pretty, but it seems to work correctly.
You can copy and paste this into the template editor (Hence the summary list at the bottom) to test.
{% set ns = namespace(duration_c1_mon = 0, duration_c2_mon = 0, duration_mon = 0,
duration_c1_tue = 0, duration_c2_tue = 0, duration_tue = 0,
duration_c1_wed = 0, duration_c2_wed = 0, duration_wed = 0,
duration_c1_thu = 0, duration_c2_thu = 0, duration_thu = 0,
duration_c1_fri = 0, duration_c2_fri = 0, duration_fri = 0,
duration_c1_sat = 0, duration_c2_sat = 0, duration_sat = 0,
duration_c1_sun = 0, duration_c2_sun = 0, duration_sun = 0,) %}
{%- for cycle in range(1,3,1) -%}
{% if cycle == 1 -%}
{%- for number in range(0,17,1) -%}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_mon') == 'on' -%}
{%- set ns.duration_c1_mon = ns.duration_c1_mon + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_tue') == 'on' -%}
{%- set ns.duration_c1_tue = ns.duration_c1_tue + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_wed') == 'on' -%}
{%- set ns.duration_c1_wed = ns.duration_c1_wed + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_thu') == 'on' -%}
{%- set ns.duration_c1_thu = ns.duration_c1_thu + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_fri') == 'on' -%}
{%- set ns.duration_c1_fri = ns.duration_c1_fri + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_sat') == 'on' -%}
{%- set ns.duration_c1_sat = ns.duration_c1_sat + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_sun') == 'on' -%}
{%- set ns.duration_c1_sun = ns.duration_c1_sun + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if is_state('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_every_day', 'on') -%}
{%- set ns.duration_c1_mon = ns.duration_c1_mon + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c1_tue = ns.duration_c1_tue + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c1_wed = ns.duration_c1_wed + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c1_thu = ns.duration_c1_thu + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c1_fri = ns.duration_c1_fri + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c1_sat = ns.duration_c1_sat + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c1_sun = ns.duration_c1_sun + states('input_number.irrigation_cycle1_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if cycle == 2 %}
{%- for number in range(0,17,1) -%}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_mon') == 'on' -%}
{%- set ns.duration_c2_mon = ns.duration_c2_mon + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_tue') == 'on' -%}
{%- set ns.duration_c2_tue = ns.duration_c2_tue + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_wed') == 'on' -%}
{%- set ns.duration_c2_wed = ns.duration_c2_wed + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_thu') == 'on' -%}
{%- set ns.duration_c2_thu = ns.duration_c2_thu + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_fri') == 'on' -%}
{%- set ns.duration_c2_fri = ns.duration_c2_fri + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_sat') == 'on' -%}
{%- set ns.duration_c2_sat = ns.duration_c2_sat + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if states('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_sun') == 'on' -%}
{%- set ns.duration_c2_sun = ns.duration_c2_sun + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{%- if is_state('input_boolean.irrigation_cycle' ~ cycle ~ '_zone' ~ number ~ '_every_day', 'on') -%}
{%- set ns.duration_c2_mon = ns.duration_c2_mon + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c2_tue = ns.duration_c2_tue + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c2_wed = ns.duration_c2_wed + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c2_thu = ns.duration_c2_thu + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c2_fri = ns.duration_c2_fri + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c2_sat = ns.duration_c2_sat + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- set ns.duration_c2_sun = ns.duration_c2_sun + states('input_number.irrigation_cycle2_zone' ~ number ~ '_duration_box') | int -%}
{%- endif %}
{% endfor %}
{% endif %}
{%- endfor %}
C1_Monday_Total_Time: {{ ns.duration_c1_mon }}
C2_Monday_Total_Time: {{ ns.duration_c2_mon }}
C1_Tuesday_Total_Time: {{ ns.duration_c1_tue }}
C2_Tuesday_Total_Time: {{ ns.duration_c2_tue }}
C1_Wednesday_Total_Time: {{ ns.duration_c1_wed }}
C2_Wednesday_Total_Time: {{ ns.duration_c2_wed }}
C1_Thursday_Total_Time: {{ ns.duration_c1_thu }}
C2_Thursday_Total_Time: {{ ns.duration_c2_thu }}
C1_Friday_Total_Time: {{ ns.duration_c1_fri }}
C2_Friday_Total_Time: {{ ns.duration_c2_fri }}
C1_Saturday_Total_Time: {{ ns.duration_c1_sat }}
C2_Saturday_Total_Time: {{ ns.duration_c2_sat }}
C1_Sunday_Total_Time: {{ ns.duration_c1_sun }}
C2_Sunday_Total_Time: {{ ns.duration_c2_sun }}
UPDATE: Fixed some spacing issues for copy and paste in page_cycles.yaml
I'm trying to find time to work on HA.... Is this still an issue?
Hi, I haven't looked recently - Still have to fix the browser_mod popup issue to double check. If I recall from the time the work around above solved the issue. I will get back to you asap.
Thank you!
Hi, I updated to your updated package - Lost some of zone names, but it is really easy to restore so no train smash there.
I checked the calculated times and it seems to be still off.
Hi,
Firstly - Thank you for implementing this, but the calculation seems to be off. Using Tuesday's Morning cycle as an example, if I calculate it by hand it should be 35 minutes.