irrigation_run_a_cycle: Error executing script. Unexpected error for repeat at pos 1: 'mappingproxy' object does not support item assignment
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 181, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 489, in _async_repeat_step
set_repeat_var(iteration)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 443, in set_repeat_var
self._variables["repeat"] = repeat_vars
TypeError: 'mappingproxy' object does not support item assignment
If it looks right I must have something else wrongâŚ
Iâm not using while, Iâm using until but yeah, in this case it doesnât matter.
However I am doing this:
my_script:
sequence:
- repeat:
until:
- condition: template
value_template: >
{{ is_state('input_number.irrigation_number_of_zones') | int == repeat.index }}
sequence:
- service: a service
- service: another service
- service: a service to do when repeat finished
I think I see the problem now. The is_state function takes two arguments and you only supplied one. In fact, I think you meant to use the states function, not is_state.
irrigation_run_a_cycle: Error executing script. Unexpected error for repeat at pos 1: 'mappingproxy' object does not support item assignment
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 181, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 489, in _async_repeat_step
set_repeat_var(iteration)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 443, in set_repeat_var
self._variables["repeat"] = repeat_vars
TypeError: 'mappingproxy' object does not support item assignment
More than one thing wrong and the use of is_state wasnât the biggest problem! Your code exposed a bug and, hopefully, pnbruckner will have a correction available in an upcoming patch release.
Really big changes in scripting so a few little bugs are bound to have slipped by the testers.
When running the the package, which was written by the original author (klogg), the irrigation automation kicks off as expected then gets stuck on the script which repeats through the configured zones.
It is the same script mentioned in the posts above - I have tried adding mode: parallel before the sequence entry, but it does not resolve the issue.
This script functioned on 0.112.4, only change to it was the testing of mode:parallel to try and resolve the issue. The package can be found at https://github.com/kloggy/HA-Irrigation-Version2
Iâm sorry, but I canât try to fix some giant package someone else wrote. If you can provide a small, reproducible example that shows that something in HA is not working, then Iâm more than happy to try and reproduce the problem, and if I can, fix it.
I called it via the SERVICES tab, passing in the variable last. As best I can tell that should simulate the problem noted in the OP. It fails w/ 0.113.1, but works just fine for me in 0.113.2.
I just added the debug logging to my HA and restarted, will see if I can find any helpful information in there to assist in finding the cause.
Appreciate your effort!
UPDATE: I checked the logs on debug, but cannot see any errors while running the script. Will remove the mode:parallel fix and see if that is perhaps now throwing things over.
UPDATE2: Still not working correctly, but I will try and pin point where the issue might be.
Just because something doesnât cause errors doesnât mean it works correctly. Have you asked the author of the âpackageâ youâre trying to use?