Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to hubitat from another network? #211

Open
jatgm1 opened this issue Apr 14, 2023 · 8 comments
Open

Connect to hubitat from another network? #211

jatgm1 opened this issue Apr 14, 2023 · 8 comments

Comments

@jatgm1
Copy link

jatgm1 commented Apr 14, 2023

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

@jason0x43
Copy link
Owner

What additional information are you looking for?

@jatgm1
Copy link
Author

jatgm1 commented Apr 14, 2023

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
Copy link
Owner

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
Copy link
Author

jatgm1 commented Apr 15, 2023

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
Copy link
Author

jatgm1 commented Apr 15, 2023

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
Copy link
Owner

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.

@rpiasentin
Copy link

I have the same issue that the original post was discussing. Very specifically, I have hubs on different networks (places as well) that are subscribed to the hub protect and remote monitoring services from hubitat ( this is in fact the example from the original post). I suspect there are many folks doing the same thing.

I have extracted an error that the integration generates and if seems that the integration is mistakenly apending an extra "/api"

i get this message in the logs:custom_components.hubitat.hubitatmaker.error.RequestError: GET https://cloud.hubitat.com/api/4ea3d66e-7d03-475d-9397-8324c32b1bdc/apps/api/14/devices?access_token=f538f7c7-c9aa-4019-b1e9-2627663c0ba9 - [404] Not Found

The error message indicates that the Hubitat integration in Home Assistant is using an incorrect URL structure. Specifically, it's appending an extra /api segment to the path, causing the request to fail with a 404 Not Found.

The problematic URL being constructed:

bash
Copy code
https://cloud.hubitat.com/api/4ea3d66e-7d03-475d-9397-8324c32b1bdc/apps/api/14/devices?access_token=f538f7c7-c9aa-4019-b1e9-2627663c0ba9
The correct URL should be:

bash
Copy code
https://cloud.hubitat.com/api/4ea3d66e-7d03-475d-9397-8324c32b1bdc/apps/14/devices?access_token=f538f7c7-c9aa-4019-b1e9-2627663c0ba9
This extra /api is likely being added automatically by the integration.

is there an easy way to make this work?

@jason0x43
Copy link
Owner

The integration assumes it's accessing the Maker API on a Hubitat hub, which has a URL of the format http://<Hubitat host>/apps/api/<app ID>/. It only asks for the host and the Maker API app ID, and it automatically fills in /apps/api/ part of the path.

However, based on your example URL, the cloud API rearranges things a bit, using the format https://cloud.hubitat.com/api/<uuid>/app/<app ID>/.

There isn't currently any way to make the cloud URL work, but it shouldn't be difficult to implement. Let me look into that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants