Remote Home Assistant won't connect to

I’m trying to use Remote Home Assistant, a custom component, so both instances of Home Assistant will be manageable as one. Both are on the same LAN, but in different buildings, too far apart for wifi to reach. The buildings are connected through an underground fiber optic cable. The address space is 172.16.7.xxx and the domain is arda.ea. Both are on RPi 4 computers, installed by writing the image to a USB memory stick or an SD card with Raspberry Pi Imager.

The main system is at 172.16.7.2 with the host name “imladris.”

The remote system is at 172.16.7.3 with the host name “lothlorien.”

I installed HACS on both systems, then installed Remote Home Assistant on the secondary system. For some reason, the first time I installed it, I did not get the dialog asking if I was using that system as the main or remote system. Since it’s a custom component, it was tough to delete. I went through HACS and deleted it, then deleted the directory and files with File Editor. I had to do this several times before it disappeared (and restarted that instance of HA at almost every step in the process, just to be sure). Finally when I started to install it, it asked if this was to be the main or remote system. I picked remote. That was all it needed and if I try to go to Integrations and pick Configure for this component, I get an error message that the file isn’t there. (I can see how this just doesn’t allow for a config change.)

On the main system, I went through the same process. After using HACS to download RHA (Remote Home Assistant) and to add it as an integration, I get the dialog asking for the address of the remote instance, the port, the authorization token, and check boxes for Secure and Verify SSL. This is where I always run into a problem.

If I enter the IP address of the remote system, and click “Submit,” I immediately get an error, “Failed to connect to server.” If I enter the host name and the domain, “lothlorien.arda.ea,” then I get the same. If I include the host name, “lothlorien” by itself, then when I hit “Submit,” it takes a while before I get the same message. I am using an Authorization Token. On the remote system, under my account, I generated a Long-Lived Access token and copied and pasted it into my Notes app. The key was still in my clipboard. Then I went to the browser tab open to the main system, with the dialog box for RHA. I paste in the Long-Lived Access token and click “Submit.” As I mentioned, if I use the host name and not the IP address or the name with my LAN domain, I have to wait, but still get the same error message.

I have tried this with the check boxes for “Secure” and “Verify SSL” checked and unchecked - and either checked and the other unchecked. It doesn’t matter.

So if I use the actual Long LIved Token, I still get the same error. I tried it with a one character token I picked at random and got the same result as with the actual token: I clicked “Submit” and it took a while and then gave me the same error.

I’ve tried looking in the logs, but I can’t find any log for this. (Maybe I’m looking in the wrong place.) I can’t tell just why there’s no connection. I’m wondering if I could be doing something wrong with generation and copying and pasting the Long Lived Token. Since I’ve done limited work on the remote system, I’m considering just putting in new media and starting over with it, in case me deleting RHA and re-downloading and re-installing it could have led to a problem.

What am I doing wrong or what can I do to get this to work?

Have you solved this? I have two HA instances 500km away from each other and want to have some sensors in one. I use this component for two instances under one roof on local LAN, which works flawlessly but the remote over internet does not. I tried tailscale VPN system, no success, I have domains, no effect.

I never could get it to behave properly and thought I had deleted it so I wasn’t using Remote Home Assistant - and then, one day, it showed up and I watched HA add all the devices in the remote building. I forgot what I did, but it just made a mess, but I basically undid it. I think I just deleted or removed all of Remote Home assistant.