Adding P2 to Home Assistant

Having added a new P2 sensor to Apple Home, how do I now add it to Home Assistant? I’ve put it into pairing mode in Home, copied the code and put it in to the Add Matter device in HA. Every time, I just get an unhelpful “Failed to add” message.

Make sure that it is in the format
0000-000-0000 and not 00000000000.
Add hyphens if necessary. Always four numbers, hyphen, three numbers, hyphen, and another four numbers.

1 Like

Thanks for that - it has crossed my mind, as I see that the auto copy function drops the dashes, but I hadn’t tried it yet. Will give it a go in the morning.

1 Like

Nope, ‘fraid not. Good idea though. Just a bland failed message with nothing in the logs

Hi @rh111 - What are you using as your Thread Border Router with Home Assistant?

Strange, I was able to add the P2 without any problems.

What kind of border router do you have?

Did you look directly at the logs in the plug-in?

There, you should at least see the entry
“Starting Matter commissioning with code using Node ID.”

Two - Apple TV 4k (which I am informed does not expose the device to other ecosystems) and an Aqara G410 doorbell. I’ve also tried adding it explicitly to the G410 in the Aqara app, but that fails too.

That seems like a larger underlying problem in your network then. Do you have IPv6 enabled on your network? Are all of these devices on the same LAN?

How are you attempting to Pair the G410 to Aqara?

Besides that, make sure your home assistant sees those Apple TVs and is using the thread network they created. In your home assistant go to /config/thread and let us know what you see. Your Apple thread network can absolutely be shared by Home Assistant.

The G410 is paired with the Aqara app and with Apple Home. What I’m trying to do is to get all its features visible in Home Assistant and to get the P2 Motion sensor added to the Aqara app and to HA as well, so that I can use the more sophisticated automation features there.

IPv6 is on for the network, but I had to disable it on the HA host Pi due to the incompatibility of the Tuya Integration with IPv6. In fact, I’ve now migrated to Tuya local, so might re-enabling IPv6 for the server improve things? (I don’t see any IPv6 requirement in what there is of Aqara documentation)

IPv6 is a core architecture requirement for Thread.

The Thread specs are pretty dense https://www.threadgroup.org/Portals/0/documents/support/Thread%20Network%20Fundamentals_v3.pdf

But here’s a summary from Aqara What Is Thread Protocol And How Does It Work? - Aqara

I thought you were on to something there: in fact, IPv6 is up and functional - I’d disabled it on a previous test server whilst trying to get Tuya to work. So all my devices appear to be receiving IPv6 addresses and are pingable with ping6, so it doesn’t appear to be that.

As far as i can see, the G410 is set up as a full Thread/Matter border router and is visible to the rest of the network, but Aqara’s diagnostics are pretty ambiguous.

But you did say in your original post that you can’t get it to pair to home assistant, right?

Correct. It appears in the Aqara app and in Apple Home, but nowhere else. that applies to both the P2 Motion Sensor (which I can’t even add to the Aqara app) and to the G410 and HA

OK specific to troubleshooting the P2 - if you go in your Home Assistant to /config/thread - what do thread networks do you see listed?

This is getting interesting: there’s no thread child in HA’s /config, and there no Thread panel appears in the HA UI. My understanding from the HA documentation is that Thread should appear automagically if HA detects a TBR, of which there are two: Apple TV 4K and the Aqara G410. What may be related is that if I ping either of those TBRs from the Matter integration, both return IPv4 addresses but fail on IPv6. Which does suggest something wrong with either the configuration or my understanding (This is me just starting to migrate stuff to Thread/Matter).

Just to confirm, this isn’t the case anymore? It does look like your HA instance can’t see your thread network(s) and perhaps doesn’t have IPv6.

My disabling of ipv6 was on a previous system, not this one (my bad - I forgot). This one both shows an ipv6 address on the Ethernet interface end0 and responds to ping6. What it doesn’t do is receive a response to an outgoing ipv6 ping from the Thread integration, as per my screenshot. Which is weird.

I’m just wondering if I’m fundamentally misunderstanding how the Apple & Aqara TBRs integrate with HA: for instance do I need a hardware TBR directly connected to my HA host Pi?

The fact that Home Assistant lists the IPv6 addresses (via mDNS discovery) but fails to ping ANY of them strongly suggests a configuration issue on the Home Assistant host itself.

Please go to Settings → System → Network in Home Assistant.
Check the IPv6 setting of your Network Adapter. It is likely set to “Disabled”. Please set it to “Automatic” (DHCP).

Once HA acts as a proper IPv6 client, the Thread integration should be able to communicate with your Border Routers

A USB stick (Thread radio) on HA is not mandatory if you already have a Border Router like the Apple TV 4K.