{% set x = states('input_number.lastricosolare_duratairrigazionepostazioneidroponica13') | int + states('input_number.lastricosolare_duratairrigazionepostazioneidroponica13') | int%}
{% set ns = namespace(n_min=[]) %}
{% for h in range(0,24) if h >= now().hour%}
{% for m in range(0, 56, 5) -%}
{%- set mod0 = ((h*60) + m) % x -%}
{%- set dt = today_at(h|string~':'~ (m|string if m < 10 else '0'~m|string)) %}
{%- set ns.n_min = (ns.n_min + [dt]) if (mod0 == 0 and dt >= now()) else ns.n_min %}
{% endfor %}{% endfor %}
{{ (ns.n_min) | reject('<=', states('sensor.sun_rising') | as_datetime)
| reject('>', states('sensor.sun_setting') | as_datetime + timedelta(hours=1)) | map("string") | list }}
Getting your error now. I should be able to find the error.
Test this
try replacing sensor.sun_setting
with sensor.sun_next_setting
sensor.sun_setting is not a legit attribute
{% set x = states('input_number.lastricosolare_duratairrigazionepostazioneidroponica13') | int + states('input_number.lastricosolare_duratairrigazionepostazioneidroponica13') | int%}
{% set ns = namespace(n_min=[]) %}
{% for h in range(0,24) if h >= now().hour%}
{% for m in range(0, 56, 5) -%}
{%- set mod0 = ((h*60) + m) % x -%}
{%- set dt = today_at(h|string~':'~ (m|string if m < 10 else '0'~m|string)) %}
{%- set ns.n_min = (ns.n_min + [dt]) if (mod0 == 0 and dt >= now()) else ns.n_min %}
{% endfor %}{% endfor %}
{{ (ns.n_min) | reject('<=', states('sensor.sun_rising') | as_datetime)
| reject('>', states('sensor.sun_next_setting') | as_datetime + timedelta(hours=1)) | map("string") | list }}
Does the code that’s working for me work for you?
{% set x = states('input_number.lastricosolare_duratairrigazionepostazioneidroponica13') | int + states('input_number.lastricosolare_duratairrigazionepostazioneidroponica13') | int %}
{% set ns = namespace(n_min=[]) %}
{% for h in range(0,24) if h >= now().hour%}
{% for m in range(0, 56, 5) -%}
{%- set mod0 = ((h*60) + m) % x -%}
{%- set dt = today_at(h|string~':'~ (m|string if m < 10 else '0'~m|string)) %}
{%- set ns.n_min = (ns.n_min + [dt]) if (mod0 == 0 and dt >= now()) else ns.n_min %}
{% endfor %}{% endfor %}
{{ (ns.n_min) | reject('<=', states('sensor.sun_next_rising') | as_datetime)
| reject('>', states('sensor.sun_next_setting') | as_datetime + timedelta(hours=1)) | map("string") | list }}
Boh!
We should have started there
This was the second issue
You have changed also:
sensor.sun_next_rising
Didn’t catch that, but you are 100% correct.
Anyway… no data output in my configuration
Did you switch back to the input_select and input_number entities?
No. Using your code above
Same if:
{% set x = states('input_select.lastricosolare_sceltaintervalloirrigazionidiurnepostazioneidroponica13') | int + states('input_number.lastricosolare_duratairrigazionepostazioneidroponica13') | int %}
{% set ns = namespace(n_min=[]) %}
{% for h in range(0,24) if h >= now().hour %}
{% for m in range(0, 56, 5) -%}
{%- set mod0 = ((h*60) + m) % x -%}
{%- set dt = today_at(h|string~':'~ (m|string if m < 10 else '0'~m|string)) %}
{%- set ns.n_min = (ns.n_min + [dt]) if (mod0 == 0 and dt >= now()) else ns.n_min %}
{% endfor %}{% endfor %}
{{ (ns.n_min) | reject('<=', states('sensor.sun_next_rising') | as_datetime)
| reject('>', states('sensor.sun_next_setting') | as_datetime + timedelta(hours=1)) | map("string") | list }}
Do you get results with this?
{% set x = states('input_select.choicedaywateringinterval') | int + states('input_number.irrigationduration') | int %}
{% set ns = namespace(n_min=[]) %}
{% for h in range(0,24) if h >= now().hour%}
{% for m in range(0, 56, 5) -%}
{%- set mod0 = ((h*60) + m) % x -%}
{%- set dt = today_at(h|string~':'~ (m|string if m < 10 else '0'~m|string)) %}
{%- set ns.n_min = (ns.n_min + [dt]) if (mod0 == 0 and dt >= now()) else ns.n_min %}
{% endfor %}{% endfor %}
{{ (ns.n_min) | reject('<=', states('sensor.sun_next_rising') | as_datetime)
| reject('>', states('sensor.sun_next_setting') | as_datetime + timedelta(hours=1)) | map("string") | list }}
I edited the previous post before your response in the sense you now requested
Why have your devices changed from the original post?
input_select.choicedaytimewateringinterval
vs input_select.lastricosolare_sceltaintervalloirrigazionidiurnepostazioneidroponica13'
Yes
in the original post I translated the name of the device into English for your better understanding.
The tests are done with the right device name
[ ]
means the formula is now working. I’ll have to test the math tomorrow. In the US and its late for me.
I can only thank you for the time you dedicated to me.
Have a nice rest