Rbillon59 / hass-n8n

Home assistant addon to host a n8n.io instance
Apache License 2.0
48 stars 15 forks source link

Import modules in code (python) node #63

Closed d8rt8v closed 10 months ago

d8rt8v commented 10 months ago

Hi! First of all, thanks for the nice addon. Works like a charm with the Cloudflared.

Still, i have a difficulty when trying to import a python module in a code node. Accourding to the offical documetation n8n downloads the package automatically the first time you use it, but in my case something is wrong and i seean an error every time I try importing.

Is it something with the build for HA or i am doing something incorrect?

image

I'm using the latest 1.0.15 vesion of an addon

Rbillon59 commented 10 months ago

Hello,

I never tried such things yet, I will take a closer look next week.

But the error message seems saying that your python code need to return an array or a dict, and may be failing because you're not returning anything.

Could you try to add a return statement, even empty, or with dummy values ?

Like return {} or return {"foo":"bar"}

d8rt8v commented 10 months ago

Yeah, my bad. This code works, thanks for a correction!

foo = [{'name': 'Bob', 'age': 30},{'name': 'Tom', 'age': 23}] print(foo[1]) return foo