jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
196 stars 48 forks source link

Trouble configuring event server #146

Open seannymurrs opened 2 years ago

seannymurrs commented 2 years ago

Sorry for my ignorance, but I am having some issues setting up the event server section of the plugin. In the Hubitat app, I put the IP address and port # of my Home Assistant installation into the "URL to POST device events to" box. Is this correct, or am I supposed to set up a separate port # to use for this? Also, I'm not sure what I should be putting (if anything) into the event server URL and event server port sections in the Home Assistant configuration. I've tried looking through the readme, as well as searching online for clarification, and I'm still a bit confused.

jason0x43 commented 2 years ago

Unless your Home Assistant instance is running in a VM or behind a proxy, you shouldn't need to set the URL or port in the Home Assistant config. If you do need to set it, the URL should be a URL that Hubitat can reach your Home Assistant instance at (e.g., http://some.address.on.your.network:port). In that situation you'd also need to expose a port for the event server to listen on; that's what you'd use for the port value.

Regardless of whether you need to configure the address or port in Home Assistant, you don't need to set the POST address in Hubitat; the Home Assistant integration will take care of that.

seannymurrs commented 2 years ago

So, in theory, I shouldn't have to put anything in either of the areas? The reason why I asked is because, while I can control my Hubitat devices via the Home Assistant UI, it doesn't appear that the device status is updating in the Home Assistant UI when the devices are controlled from elsewhere. Since that is the case, I'm assuming I need to configure this section. My Home Assistant installation is in a Docker container on my Mac. If I'm understanding you correctly, I would put the IP of my Home Assistant installation in the Home Assistant config. Would I also need to manually select a port (and configure that port via Docker) as well? Then, I'd leave the POST address in Hubitat blank. Does that sound correct? Thanks!

Thanks,

Sean Murray

On October 19, 2021 at 13:09 GMT, Jason Cheatham @.***> wrote:

Unless your Home Assistant instance is running in a VM or behind a proxy, you shouldn't need to set the URL or port in the Home Assistant config. If you do need to set it, the URL should be a URL that Hubitat can reach your Home Assistant instance at (e.g., http://some.address.on.your.network:port). In that situation you'd also need to expose a port for the event server to listen on; that's what you'd use for the port value.

Regardless of whether you need to configure the address or port in Home Assistant, you don't need to set the POST address in Hubitat; the Home Assistant integration will take care of that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

jason0x43 commented 2 years ago

My Home Assistant installation is in a Docker container on my Mac.

Running in Docker counts as running in a VM. 😄

The issue with VMs is that the HA instance isn't on the same network as Hubitat. It has some internal network address assigned by Docker on a subnet that Hubitat can't see. By default, the integration tells Hubitat to try to connect to it on Home Assistant's IP address. If that's some hidden internal address, Hubitat won't be able to send messages back to HA (which is the issue you're seeing).

You need to set the event server URL in HA to use the address or hostname of your Mac (something Hubitat will be able to see). For the port, you can setup a port mapping from a known port on your host to a known port in the HA container, and then set that as the port in the integration.

wdehoogh1 commented 1 year ago

You need to set the event server URL in HA to use the address or hostname of your Mac (something Hubitat will be able to see). For the port, you can setup a port mapping from a known port on your host to a known port in the HA container, and then set that as the port in the integration.

I apologize for my ignorance but I'm very new to working with containers.. When I set up the docker container on my host (which has a local IP address of 192.168.86.165), I believe I did this mapping by using the following command: -p 8123:8123. So, from any computer on the network, I can access my HA by going to the host:port (http://192.168.86.165:8123). Should I be able to just provide this URL to the Event Server URL field? Or am I missing some step?

When I do add http://192.168.86.165:8123 to the Event Server URL, I am unable to restart Home Assistant and access the home page.

jason0x43 commented 1 year ago

So, the integration's event server is a simple standalone server. It will listen on its own port (Home Assistant already uses port 8123). Normally it listens on a random port, and then tells Hubitat what that port is when the integration starts up. However, when you're running in a docker container, you need it to use a known port so you can expose the port to the rest of the network.

You'll need to pick a specific port for the event server to listen on, and then map that with docker. For example, if you wanted to use port 12345, you'd configure the integration with:

Then you'd add -p 12345:12345 to your docker command. The only requirement is that you pick a port that nothing else on is using on the system running Docker (and it probably needs to be > 1024).

wdehoogh1 commented 1 year ago

Ahhh.. I see, that makes a lot more sense. Thank you so much for the help.