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

Status not updating in HomeAssistant #120

Closed
ja-finn opened this issue May 6, 2021 · 6 comments
Closed

Status not updating in HomeAssistant #120

ja-finn opened this issue May 6, 2021 · 6 comments

Comments

@ja-finn
Copy link

ja-finn commented May 6, 2021

Hi

I'm struggling to get the POST events from Hubitat to make it back to the plug-in. The plug in communicates with Hubitat and updates the POST address/port correctly. Switches turns off when controlled by HomeAssistant and the status is updated in Hubitat but not in HA.

I'm running HA in docker swarm mode.

$ docker service ls
ID             NAME                    MODE         REPLICAS   IMAGE                                                                               PORTS                                                              
lm2h09cussxe   homeassistant_app       replicated   0/1        homeassistant/home-assistant:2021.5.0                                               *:1883->1883/tcp, *:8123->8123/tcp, *:38110->38110/tcp

Netstat inside the container shows the port listening

# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN      210/python3         
tcp        0      0 172.18.0.3:38110        0.0.0.0:*               LISTEN      210/python3         
...

Probing the ports are successful for HA web interface but not for the plug-in

$ nmap -p 8123 192.168.50.133
Nmap scan report for 192.168.50.133
Host is up (0.0024s latency).

PORT     STATE SERVICE
8123/tcp open  polipo

$ nmap -p 38110 192.168.50.133
Nmap scan report for 192.168.50.133
Host is up (0.0026s latency).

PORT      STATE  SERVICE
38110/tcp closed unknown

I assume that it should have responded to this?

Log from Hubitat

app:3122021-05-06 14:19:57.005 debugdevice event: {"name":"switch","value":"off","displayName":"Office bulb 1","deviceId":"378","descriptionText":"Office bulb 1 was turned off","unit":null,"type":null,"data":null}
dev:3782021-05-06 14:19:56.975 infoOffice bulb 1 was turned off
app:3122021-05-06 14:19:56.692 debugdeviceItem called
app:3122021-05-06 14:19:56.689 debugExecuting command: off on device: Office bulb 1
app:3122021-05-06 14:19:56.673 debugfindDevice called
app:3122021-05-06 14:19:56.669 debugsendDeviceCommand called

Log from HA

homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:48 DEBUG (MainThread) [custom_components.hubitat.device] Initializing Hubitat hub with event server on port 38110                                                                  
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:48 DEBUG (MainThread) [hubitatmaker.hub] Setting host to 192.168.50.100                                                                                                            
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:49 INFO (MainThread) [hubitatmaker.hub] Created hub <Hub host=192.168.50.100 app_id=312>                                                                                           
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:49 DEBUG (MainThread) [hubitatmaker.hub] Listening on 172.18.0.3:38110                                                                                                             
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:49 INFO (MainThread) [hubitatmaker.hub] Setting event update URL to http%3A%2F%2F192.168.50.133%3A38110                                                                            
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Loaded device list                                                                                                                        
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Loading device 377                                                                                                                        
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Loaded device 377                                                                                                                         
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Loading device 378                                                                                                                        
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Loaded device 378                                                                                                                         
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Connected to Hubitat hub at 192.168.50.100                                                                                                
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Loaded modes
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [hubitatmaker.hub] Loaded hsm status                                                                                                                         
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 DEBUG (MainThread) [custom_components.hubitat.device] Registered platforms                                                                                                      
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:18:50 INFO (MainThread) [custom_components.hubitat] Hubitat is ready
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:19:57 DEBUG (MainThread) [custom_components.hubitat.light] Turning off Office bulb 1
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:19:57 DEBUG (MainThread) [hubitatmaker.hub] Sending command off(None) to 378
homeassistant_app.1.rx2e66wazy6a@homeassistant    | 2021-05-06 14:19:57 DEBUG (MainThread) [custom_components.hubitat.device] sent off to 378

Versions
Home Assistant: 2021.5.0
Hubitat integration: 0.6.6
Hubitat: 2.2.7.121

@jason0x43
Copy link
Owner

I wonder if the plugin is listening on the wrong interface. It attempts to find the correct interface by pinging the Hubitat hub and listening on whatever interface that message went out on, which works on a standard HA distribution on a Pi and with the docker container I develop on. Maybe it should just listen on 0.0.0.0.

@ja-finn
Copy link
Author

ja-finn commented May 6, 2021

That could actually be it, the container has multiple interfaces

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
190: eth1@if191: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc noqueue state UP     link/ether 02:42:0a:00:05:20 brd ff:ff:ff:ff:ff:ff
    inet 10.0.5.32/24 brd 10.0.5.255 scope global eth1
       valid_lft forever preferred_lft forever
192: eth2@if193: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP     link/ether 02:42:ac:12:00:03 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.3/16 brd 172.18.255.255 scope global eth2
       valid_lft forever preferred_lft forever
194: eth0@if195: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc noqueue state UP     link/ether 02:42:0a:ff:00:1b brd ff:ff:ff:ff:ff:ff
    inet 10.255.0.27/16 brd 10.255.255.255 scope global eth0
       valid_lft forever preferred_lft forever

Any reason why it can't just listen on 0.0.0.0 like the HA interface does? Is it so it can supply the IP to Hubitat plugin?

@ja-finn
Copy link
Author

ja-finn commented May 6, 2021

I'll try to launch it again this evening and just connect it to a single network, see if that solves it.

@ja-finn
Copy link
Author

ja-finn commented May 6, 2021

I weren't actually able figure out how to launch it with a single interface in swarm mode. I've tried removing the exposed port from the config and then running docker service update --publish-add published=38110,target=38110,mode=host homeassistant_app after it is launched. This works and the status updates as it should.

I guess this means you are correct, that the traffic is routed to a different interface than what the integration is bound to.

Edit: for completeness if anyone else runs into the same issue, it works by publishing your port in host mode in your stack file. Note that it needs to be v3.2+ for this to work

...
    ports:
      - '8123:8123'
      - mode: host
        target: 38110
        published: 38110
        protocol: tcp
...

@ja-finn
Copy link
Author

ja-finn commented May 6, 2021

I'm closing this as I'm happy with the workaround. I didn't find any similar issues with anyone running HA in swarm mode so I'm guessing it's an edge case.

Thank you very much for pointing me in the right direction:)

@jason0x43
Copy link
Owner

I like the idea of listening on 0.0.0.0; I don't see any reason off the top of my head why that wouldn't work. I opened an issue in hubitatmaker (the library that's actually doing the listening) to 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

2 participants