Full n8n AI integration

Wouldn’t it be cool if homey pro would have full n8n integration?

imagine an agentic AI system controlling your house like Hall 2000!

a system like this could make flows obsolete. It could sense what you want or what you are doing and use AI to determine what devices it need to take a certain action on. It could be a self-generating, dynamic, advanced Flow engine!

It could sense any state change on any device and determine what action it needs to take. It could be whatever you want it to be, an ultimate butler or an advanced security guard.

It would not require you to statically define all scenarios in flows, but would dynamically reason what needs to be done. And it could learn from your behavior and adjust its actions automatically. Possibilities are endless.

Nothing is as changeable as the human mind. So there will be no system that really knows what I want. The way I react to my surroundings today will be different from tomorrow. That is why my sunscreen only work automatically when I am not at home. As some times I am sitting in the winter garden and I like the rising sun to come in, and some times I don’t. And it is really contra productive when reading the news paper and I like the sun to come in, I have to disable the automatic control of the screens and send the screens up again.

2 Likes

While the idea is cool, with the current level of “AI” there is nothing intelligent there.

If I see how many mistakes(?) it currently makes with a small wrong input from my side, or just down right wrong even if my input was proper anyway.
I definitely don’t want any AI running my house.

Where as @Rmb already mentioning my days are never the same, I might even make up my mind throughout the day, doing something completely different then I wanted in the morning.
Making it extra difficult.

1 Like

I’m sorry, Dave. I’m afraid I can’t do that

17563985276503126795058195700944

1 Like

Small update, big impact:

I’ve managed to hook Homey Pro to N8N. In N8N I was able to read out the states of all the (300+!) devices from my home, analyze them and have AI recommend actions for changing device settings.

At this moment I store the recommendations, which are surprisingly good. Next step is that I let AI generate json-code that I can feed back via a webhook into Homey Pro.

This way I have built an auto-adapting, autonomous AI driven smart home.

I even devised a term for it: an Agentic Home (from Agentic AI and Smart Home).

Once you got some basics running and the integration going, it is really low-code. I am no software engineer and can hardly even read code.

but now I have a platform for nearly limitless possibilities for autonomous AI integrations and control.

My dream is building an AI butler that anticipates and proactively acts by controls my house. A servant you have to instruct: clean my house. A butler makes sure your house is clean before you noticed it needed cleaning. That’s the difference.

Is it scary? Yes! I either get the perfect butler or HAL-2000 goes rogue and takes over my house!

But that’s what experimentation is about: to boldly go where no one has gone before!

2 Likes

This is awesome! Have you had any time to work on it since your last post? I’m definitely following this thread.

I literally just discovered n8n today because YouTube recommended this video to me: https://www.youtube.com/watch?v=budTmdQfXYU

It’s a great introduction to what’s possible with n8n, and it immediately made me think of your project. The way he builds an AI agent to manage his homelab seems very similar to what you’re trying to achieve with your “Agentic Home.”

Could you give a few concrete examples of this recommendations and elaborate why they are good?

NetworkChuck is exactly one of the few people I know of who try this stuff and to some extent inspired me. He does take a bit of a different route where he lets N8B AI agents orchestrate his home lab, but more from a technical, IT, perspective. That’s not what I am aiming for. I also gave the situation some thought and tried some stuff. The difference is fundamental.

Every event that occurs has a trigger. The sum of all triggers, and prior knowledge, is context and what I hope to achieve is that with enough context an algorithm can derive intent. This is what I call a “Probabilistic Connect Engine” that generates a “State Probability Fabric” of all properties of all devices in my home. The algorithm for that is based on Bayesian Inference. It might go a bit deep to explain that here. In essence prior knowledge (triggers) can generate probabilistic, posteriori hypotheses (intents). And intents can be translated into actions.

Based on inferred intent, many actions can easily be determined even without the help of AI, which is way faster and cheaper in resources. There are, however, some situations that are ambiguous. In those cases I intend to use AI to resolve a solution.

An example: it is warm inside, the sun is shining, but the wind is increasing. The first two triggers suggest to put the sun screens down (comfort and energy saving). However, the increased wind requires te sun screens to pull up (safety). So, depending on the triggers, the intents that are inferred are “comfort” and “energy saving”, but blocked by the inferred intent “safety”.

Or an example where the homey setup is expanded:

Lets say I have a switch in a room that switches on all the lights in that room in a certain lighting scene or mood. Now, I buy an additional light, perhaps a freestanding light, and add it to the room. In the old way I would have to add this light to all pre-defined automations. This is fine in small setups, but quickly become unmanageable when the devices and capabilities grow. The number of possible permutations explode. In my setup it would be automatically inferred that if all lights go on, also this new light might have to go on. Unless I manually override it, for instance through an app, in which case it would be inferred that this light is operated differently. The system would learn by constantly adjusting its inference weightings.

Like Chuck, I conclude the AI resolution part to be done in a stepped approach: first an AI router/orchestrator decides which specialized AI agent needs to be involved (security, comfort, energy, etc). Than the outputs of these specialist agents need to be resolved for conflicts. And finally, I intend to run it past a “governance” agent, that specifically has the task to check if it is within guardrails (I don’t intend to have a “human in the loop”).

I’ve written a high level architecture document and published a bit on my LinkedIn profile. See architecture diagram below. Obviously there is more to it, like heuristics, that can greatly reduce the workload of an automation engine. And I have done some partial performance and scaling tests and cost calculations. My home had 317 devices (:face_with_open_eyes_and_hand_over_mouth: ) and more than 1500 capabilities (sensors and actuators). Some constantly generate triggers (like energy sensors), others hardly ever. I had Homey pull all states of all capabilities every minute and the amount of data that you can generate quickly becomes a serious challenge and cost. There are all kinds of practical considerations to be taken into account: hardware, performance, storage, AI, data privacy, etc, etc.

I’v not been able to work any further on it. I was work-constrained and I was on holiday… Not sure if I will bring it further, because it stretches my IT skills quite a bit. I am more of a conceptual guy (physicist) than an engineer. And there are probably practical hurdles to be solved. But I believe it could work.

And Philips’ recent announcement of MotionAware (using RF Sensing in their Hue light bulbs) opens an enormous tsunami of possibilities, only necessitating even more an approach like the probabilistic one I took.

Let me know if you want a more detailed document I wrote explaining it conceptually (23 pages).

2 Likes

Wow this is sick! do you mind sharing your N8N template?
i have a local N8N instance

thanks!

When I pulled all states of all capabilities of all devices (a “snapshot”, if you will) and manually pulled this through AI it quickly found opportunities for energy saving, for instance, even without telling it exactly what to look for. However, this was very crude and mainly manual because I hadn’t automated it yet. I used this experience and test to scale and work out a more fundamental solution. See my reply to BillyBoy above.

This is exactly what i was thinking about doing when i saw the networkchuck video of letting terry control his homelab. Brillante youballready took a headstart with this. I just put up my local n8n instance today but im very interested in your n8n workflow json, can you please share this?

I like your thinking on letting ai control the flows in your smart home environment, i have the same ideas and want to build this:)

for the read and store part of getting all the devices from your homey in n8n I have used the following workflow:

{
  "name": "Homey Pro • Read & Store",
  "nodes": [
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 5
            }
          ]
        }
      },
      "id": "CronTrigger",
      "name": "Cron • Every 5 min",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [280, 280]
    },
    {
      "parameters": {
        "url": "={{($env.HOMEY_BASE_URL || 'http://homey_local_ip')}}/api/manager/devices/device",
        "options": {
          "response": "json",
          "timeout": "={{$env.DEFAULT_TIMEOUT_MS || 10000}}"
        },
        "authentication": "none",
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "={{'Bearer ' + $env.HOMEY_TOKEN}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "id": "HttpGetDevices",
      "name": "HTTP • Get Devices",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [560, 280]
    },
    {
      "parameters": {
        "functionCode": "const now = new Date().toISOString();\nconst payload = items[0].json;\nconst devices = Array.isArray(payload) ? payload : (payload.devices || []);\nconst out = [];\nfor (const d of devices) {\n  const caps = d.capabilitiesObj || d.capabilities || {};\n  out.push({ json: {\n    timestamp: now,\n    deviceId: d.id || d._id || d.deviceId,\n    name: d.name,\n    zone: d.zone || d.room || d.zoneName,\n    class: d.class,\n    reachable: d.available ?? d.reachable ?? true,\n    capabilities: Object.keys(caps),\n    values: caps,\n    raw: d\n  }});\n}\nreturn out;"
      },
      "id": "FnFlatten",
      "name": "FN • Flatten Devices",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [820, 280]
    }
  ],
  "connections": {
    "Cron • Every 5 min": {
      "main": [
        [
          {
            "node": "HTTP • Get Devices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP • Get Devices": {
      "main": [
        [
          {
            "node": "FN • Flatten Devices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

you just need your local ip address from the homey (if you’re running n8n locally) and an api key which you can get on the homey web app.

for now im working on the control flow to control some devices, if anybody has this working please share your findings :slight_smile: