#Error: Error rendering data template: TypeError: 'NoneType' object is not iterable

1 messages · Page 1 of 1 (latest)

granite halo
#

I am trying to create a Blueprint to change the LED colors on several types of Inovelli switches. I am having trouble with the zigbee switch portion of the automation. I am getting the Error: Error rendering data template: TypeError: 'NoneType' object is not iterable error and I've narrowed it down to the line that is tryign to get the device IEEE from the device ID. I suspect repeat.item isn't being passed through correctly but I'm unable to determine for sure that's the issue.

Code: https://gist.github.com/JDIacobbo/24ff28f17cc4bb08380b290a23f22aa3

Suspected problem on line 177:
ieee: '{{ (device_attr(repeat.item, "identifiers")|list).0.1 }}'

Error image attached.

Gist

GitHub Gist: instantly share code, notes, and snippets.

sonic goblet
#

I don’t know why you are using a repeat at all. Just complete the actions in order one after another. You aren’t doing anything with the repeat anyway

sonic goblet
#

But the code on line 177 gives you an error because you are passing a string that is not a device id into the device_attr function

This is what you are doing, and pasting this into the template editor will of course generate the same error you got:
{{ (device_attr('inovelli_blue_2_in_1', 'identifiers') | list).0.1 }}

granite halo
#

My understanding was that the repeat was iterating through all of the device IDs in the list inovelli_blue_2_in_1 entered in the input, performing the action on each.

#

It does look like I could get away with not using a repeat for the first five conditions because I'm using multicast and can just list all of the devices at once. But for the zigbee devices I need to process each one at a time. Is there a way to use a loop to iterate through all of the devices in a variable list?

sonic goblet
#

The repeat will iterate through each item you provide to it, and you provided a list of strings. I figured you knew that because your condition explicitly tests that the repeat.item equals the string 'inovelli_blue_2_in_1'

granite halo
#

Yeah, I guess at one point I did. I started this BP a while ago and have been relearning a lot to finish it.

#

And that makes sense based on the script docs I was reading earlier for for_each loops.

#

So I guess my question is, how do I iterate on the contents of a variable?

#

*variable list

sonic goblet
sonic goblet
#
variables:
  my_variables:
    my_first_variable: 123
    my_second_variable: 'hello'
    my_third_variable: "{{ 1 + 2 }}"

Then you could iterate through each dict item in my_variables

granite halo
#

Is there a way to convert the input list into a dict when defining variables?

sonic goblet
#

I'm not understanding what you're asking. What do you mean by the "input list"?

granite halo
#

The BP uses device selector to create a list of device IDs:

  input:
    inovelli_dimmer:
      name: Inovelli Dimmer
      description: List of available Inovelli dimmers.
      default: []
      selector:
        device:
          filter:
            - integration: zwave_js
              manufacturer: Inovelli
              model: LZW31-SN
            - integration: zwave_js
              manufacturer: Inovelli
              model: LZW31
          multiple: true
#

Variable are then created from those lists created from the input:

variables:
  color: !input color
  inovelli_dimmer: !input inovelli_dimmer
  inovelli_switch: !input inovelli_switch
  inovelli_fan_light_combo: !input inovelli_fan_light_combo
  inovelli_red_2_in_1: !input inovelli_red_2_in_1
  inovelli_blue_2_in_1: !input inovelli_blue_2_in_1
sonic goblet
#

sorry I didn't notice you were using multiple: true

#

I don't use blueprints, so I'd only be guessing, but I would expect the variable to be populated with a list of device id's, and you could loop through each one.

Now I need to look at your BP again and see if that is what you were trying to do.

granite halo
#

Yeah, thats what I was trying to do

sonic goblet
#

if you select multiple devices for one of the selections, your blueprint doesn't loop through them. Your repeat only goes through the list of strings, one at a time

#

you need a repeat loop inside your existing repeat loop. Or, just remove the loop you have, and create 5 repeat loops, one for each variable. There's no need to have an outer loop

granite halo
#

Make's sense. I'll try it.

#

Looks like I can't list multiple repeat loops, give me a duplicate key error

sonic goblet
#

you're not listing them. A list starts with a dash

granite halo
#

Yup, just saw that

sonic goblet
#

should be something like this

  - repeat:
      for_each: "{{ inovelli_switch }}"
      sequence:
        - action: blah blah