jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
191 stars 46 forks source link

Connect to hubitat from another network? #211

Open jatgm1 opened 1 year ago

jatgm1 commented 1 year ago

I cannot figure out how to connect from another network. Can someone add that to the readme?

jason0x43 commented 1 year ago

What additional information are you looking for?

jatgm1 commented 1 year ago

So basically where do I figure out what url to enter? Because I tried doing what it said on a forum which is replace the IP address with the thing in maker api that it starts with. Like I entered

https://cloud.hubitat.com/api/1c28d333-7fae-4564-9c00-97182f7ce124/apps/215/

Then I reentered 1c28d333-7fae-4564-9c00-97182f7ce124

As the API access token then

215

as API app id

And left everything else blank. Both networks have their own no-ip domain.

So do I need to add the no-ip domain of the home assistant to the "Enable these hosts" and "url to post events to" or no? I'm not sure if im doing it right here.

(I can change the account token if it's a security risk or whatever or you can private or delete this if it's an issue but I'm just trying to be thorough here.

jason0x43 commented 1 year ago

The assumption is that HA and Hubitat are on the same network. However, it should work on different networks -- the base requirement is just that HA must be able to see whatever address you give as the Hubitat host address, and Hubitat must be able to see the event server URL. If HA and Hubitat are on different networks, you'll need to manually provide the event server URL (because the automatically set one isn't going to work). It will will need to be a hostname or address that Hubitat can use to reach your Home Assistant instance. In that case you'll probably also want to specify an event server port, just to have a stable value, and you'll need to do any necessary port mapping on your router and/or container server.

jatgm1 commented 1 year ago

Ohh, it said on some forums to leave it empty so I assumed it used some kinda dynamic way of dealing with multiple ports, okay thank you. Would you be able to help me to understand what url I should be using though? Was that the correct url? Like if those were the correct token and app id would that be a correct way of doing it? Also should I use http or https? And can the default ssl certificate from letsencrypt on my home assistant be sufficient for ssl encryption?

jatgm1 commented 1 year ago

Also how do I specify where the certificate is? Does it need to be in the same network and use like samba to access it? If not do I have to manually add it to the home assistant somehow every time it renews? (I assume unencrypted access is a security nightmare)

jason0x43 commented 1 year ago

Ohh, it said on some forums to leave it empty so I assumed it used some kinda dynamic way of dealing with multiple ports

It does, but that’s really only useful if HA and Hubitat are on the same network. In that case, the integration will serve on a random port and automatically configure Hubitat with a URL to send events to. If HA and Hubitat are on different networks, the URL the integration comes up with probably won’t work, so you’ll need to provide one. If you’re manually providing a URL, you’ll also want to manually set the port to a fixed value.

Would you be able to help me to understand what url I should be using though?

That really depends on your setup. From your Hubitat’s perspective, what is an address or host name it should be able to use to get to a server running on your Home Assistant instance? That’s generally the externally visible URL or IP address of your HA instance + the port number the integration’s event listener server is running on. So if Hubitat can see your HA instance at http://myhass.com, and the integration’s event server is running on port 12345, the event server URL should be http://myhass.com:12345.

And can the default ssl certificate from letsencrypt on my home assistant be sufficient for ssl encryption?

It should be.

Also how do I specify where the certificate is?

You specify the path to a certificate in the integration config. That path is relative to config/ directory.