Improve HomeAssistant

First: I love n8n,

now comes the “but”:

I’m using Home Assistant very much and today I tried to move my Automations to n8n, because I don’t realy like NodeRed.

What I found is, that there is an essential feature missing:
An Trigger on which you can react to a change of a state like in NodeRed
image

Another improvement would be, if we could get an entity list in the call service Action:

So you wouldn’t have to switch between Home Assistant (to get the entity_id) and n8n.
That’s how it looks in NodeRed:

I realy think, that many from the NodeRed Community (especially beginners) would come to n8n and contribute.

What are your thoughts about this?

Kind regards

Hi there,

I want to do the same, because I also dislike nodered.

Next year(nov) I will be redoing my whole HA setup including converting everything to n8n. Will probably do a PR or Community node with updated features to make my own life easier as well. :slight_smile:
So if noone else is doing it you can atleast be sure it will be done next year. Will be a bit of a wait but it is the best I can do. :slight_smile:

2 Likes

With “Next year (nov)” - do you mean November next year?
I hope I will somehow get the updates, so I can move my stuff to n8n, too.
Maybe if you would think of me then, I could help beta-testing. My Programming skills sadly are only very good in PLC Programming - so I think, I may not be a big help…

Yes that is correct.
I will of course post it here when it is done.

1 Like

I started on a websocket based trigger a while back that loaded entities etc. problem was dealing with connection outages and problems… a skill issue on my side only.

How did you manage the subscriptions and authentication? All in n8n? All in a Code Node? Seems to be a lot of effort for many entities…

No, I wrote a custom node for it. I was struggling to find it again, turns out it’s tucked away in a 2 year old branch. This was started back when there was no such thing as custom nodes

2 Likes

Thank you very much! I hoped it would be easier to implement, then to create a custom node. I’ve no experience in programming ts.

I’m trying to understand the code and when I’ve got time I’ve to create and dev VM to learn… a long way to go :see_no_evil:

It could be easier, one of the core n8n was working on a generic websocket node that might’ve worked for your purpose

Is this gonna be easier to dev now? Have no experience with websockets, so that might get tricky :thinking:

Tried to find something generic, but couldn’t find anything in the forums or anywhere else…

I’m going to create another therad in the “Questions” section, maybe I’ve overlooked something.

I’m tried to create a HomeAssistant Trigger. AI helped a lot :wink:

But I couldn’t get it to run. Build is successfull, but when starting n8n I got an error and I couldn’t figure out, how to solve it:
My repo: ptC7H12/n8n-nodes-homeassistanttrigger: Example starter module for custom n8n nodes.

Error:

User settings loaded from: /home/MySpace/.n8n/config
Initializing n8n process
Error loading node "globals" from: "/home/MySpace/.n8n/custom/node_modules/n8n-nodes-homeassistanttrigger/node_modules/engine.io-client/build/cjs/globals.node.js" - require(...).globals is not a constructor
evalmachine.<anonymous>:1
new (require('/home/MySpace/.n8n/custom/node_modules/n8n-nodes-homeassistanttrigger/node_modules/engine.io-client/build/cjs/globals.node.js').globals)()
^

TypeError: require(...).globals is not a constructor
    at evalmachine.<anonymous>:1:1
    at Script.runInContext (node:vm:134:12)
    at loadClassInIsolation (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/ClassLoader.ts:9:16)
    at CustomDirectoryLoader.loadNodeFromFile (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:91:35)
    at CustomDirectoryLoader.loadAll (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:335:9)
    at LoadNodesAndCredentials.runDirectoryLoader (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:270:3)
    at LoadNodesAndCredentials.loadNodesFromCustomDirectories (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:181:4)
    at LoadNodesAndCredentials.init (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:100:3)
    at Start.init (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts:72:3)
    at Start.init (/usr/local/lib/node_modules/n8n/src/commands/start.ts:192:3)
Exiting due to an error.
Error: Exiting due to an error.
    at Start.exitWithCrash (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts:151:23)
    at Start.catch (/usr/local/lib/node_modules/n8n/src/commands/start.ts:363:14)
    at Start._run (/usr/local/lib/node_modules/n8n/node_modules/@oclif/core/lib/command.js:306:29)
    at Config.runCommand (/usr/local/lib/node_modules/n8n/node_modules/@oclif/core/lib/config/config.js:424:25)
    at run (/usr/local/lib/node_modules/n8n/node_modules/@oclif/core/lib/main.js:94:16)
    at /usr/local/lib/node_modules/n8n/bin/n8n:71:2

require(...).globals is not a constructor
evalmachine.<anonymous>:1
new (require('/home/MySpace/.n8n/custom/node_modules/n8n-nodes-homeassistanttrigger/node_modules/engine.io-client/build/cjs/globals.node.js').globals)()
^

TypeError: require(...).globals is not a constructor
    at evalmachine.<anonymous>:1:1
    at Script.runInContext (node:vm:134:12)
    at loadClassInIsolation (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/ClassLoader.ts:9:16)
    at CustomDirectoryLoader.loadNodeFromFile (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:91:35)
    at CustomDirectoryLoader.loadAll (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/DirectoryLoader.ts:335:9)
    at LoadNodesAndCredentials.runDirectoryLoader (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:270:3)
    at LoadNodesAndCredentials.loadNodesFromCustomDirectories (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:181:4)
    at LoadNodesAndCredentials.init (/usr/local/lib/node_modules/n8n/src/load-nodes-and-credentials.ts:100:3)
    at Start.init (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts:72:3)
    at Start.init (/usr/local/lib/node_modules/n8n/src/commands/start.ts:192:3)

Bad news… the generic websocket node I was talking about by an n8n core dev… just got closed :frowning:

I’m experiencing an issue with the integration between Home Assistant and devices connected via TUYA. When I send a state with the value OFF to Home Assistant, the state changes correctly in Home Assistant, but the device does not turn off in TUYA.

However, if I use the button directly in Home Assistant to control the device, it works perfectly, and the device responds in TUYA as expected.

Has anyone encountered this issue before or have any suggestions to resolve this inconsistent behavior?

Hi @DCJr

Please open a new topic for your issue.
This topic is a feature request for the home assistant node.

When I remember right, you can’t set a state. This definitely a bug. Workaround is to call a service instead of setting a state…

And upvote this topic :wink:

Would this be the call?

What should I include for the domain?

service

Look into your tuya entity. Which kind of device is it (light, switch, etc.) Then select the one, which is the same as your entity.

Please upvote…

Btw. This a a feature request thread and not for support. You should open a new one and we can then help you there…

1 Like