home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.29k stars 30.61k forks source link

Homekit intermittent problem with 'No response' on IOS devices #15675

Closed jr3us closed 5 years ago

jr3us commented 6 years ago

Home Assistant release with the issue:

Version 74.0 on hassbian stretch running on a raspberry pi 3b. I have also tried a 3b plus, but have same problem.

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):

I am using hassbian

Component/platform:

Description of problem:

I am having an intermittent problem with the homekit builtin bridge. Sometimes all the accessories show no response in the IOS Home app, and to my experience the only way to get them back is to trigger homekit in the web interface. I am currently on HA .74.0.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

I have the following information in configuration.yaml. Note that I do have z-wave, so I added the automation to start HomeKit after wave is ready/complete.

homekit:
  auto_start: False

automation:
  - alias: 'Start HomeKit'
    trigger:
      - platform: event
        event_type: zwave.network_ready
      - platform: event
        event_type: zwave.network_complete
    action:
      - service: homekit.start

# Show links to resources in log and frontend
introduction:

logger:
  default: warning
  logs:
    homeassistant.components.homekit: debug
    pyhap: debug

Traceback (if applicable):

Additional information:

I am using an apple tv 4k as the homekit hub, but it doesn't appear to be involved when the IOS devices are attached to the same network as the HA server is.

In the following debug statements, 192.168.1.20 is my Apple TV 4k, and 1.29168.1.23 is my iPhone:

2018-07-20 12:31:00 DEBUG (Thread-26) [pyhap.accessory_driver] Could not send event to ('192.168.1.20', 55172), probably stale socket.
2018-07-20 12:31:00 DEBUG (Thread-26) [pyhap.accessory_driver] Could not send event to ('192.168.1.23', 49531), probably stale socket.

Any ideas where I have gone wrong? Any additional information I need to provide?

pleeja commented 6 years ago

What do you mean by triggering HomeKit in the web interface?

jr3us commented 6 years ago

Apologies for the confusion. The I triggered the automation referenced above through the web interface.

Additional notes:

I tried a different raspberry pi, and still received the errors, and also moved the pi to a different ethernet port on the switch as well as using a different ethernet cable. neither of these 3 steps changed anything regarding the issue or the debug statements.

I then also recreated the hassbian server with a fresh download of the hassbian image and I am still having the issue.

Thanks!

jr3us commented 6 years ago

Any ideas how I can troubleshoot this? I am getting a bit lost in the layers of classes for homekit.

I am particularly interested in finding where I can put in some debug statements for incoming requests from the iOS device. Thanks!

kirichkov commented 6 years ago

I have a similar issue, but triggering the homekit.start automation doesn't help at all. HomeKit stopped working on my iOS 11.4 devices, but is working just fine on an old iPhone running ios 9.3.5. I'm suspecting it's an iOS/ AirPlay2 - related issue, introduced with ios 11.4.1, rather than a HASS issue.

The only thing that actually resolves the problem is restarting the iOS device and it works for some time, then after a while I get "not responding".

jr3us commented 6 years ago

I have also found that restarting the home assistant server will also give it a roughly 1 hour time for it to work correctly, and not give the not responding message.

jr3us commented 6 years ago

I wonder if it could be related to power saving in iOS turning off wifi when not in use and the stale sockets may not be stale.. Pure guessing on my part.

kirichkov commented 6 years ago

I'm also speculating something similar I have extremely often power cuts so my Raspberry Pi and my WiFi router to restart qiute often and this might be causing ios, being battery powered, to not properly close the communication sockets and trying to reuse them, while they are closed on the other side.

basvankuijck commented 6 years ago

I've got a similar problem. I've installed HASS manually on my raspberry pi. Configuration of home kit in configuration.yaml is as simple as:

homekit:

The problem occurs every morning when I wake up and want to turn on my lights using siri (-> Apple home app). The home app tells me all of the accessories are not responding. After opening the home-assistant iOS app, the accessories in the apple home app immediatelly respond.

ASchneiderBR commented 6 years ago

Same problems here... When using over 4G (iPad as Hub) all accessories shows as unavailable but they work and update state. Only the Home Assistant bridge is unavailable. Using it on LAN everything works perfectly. Thanks.

SebDominguez-zz commented 6 years ago

I was having the same issue using node-red and homebridge. I thought that switching to hassio with native homekit support would help.

jr3us commented 6 years ago

Did hassio help the IOS homekit connection?

SebDominguez-zz commented 6 years ago

Unfortunately no, I’m having the exact same behavior that with Homebridge / HAP-Nodejs. Home.app works for a couple of hours and then the objects are “not responding”. Rebooting the Pi fix the issue temporarily. I noticed that if I’m experimenting an internet outage/ router reboot trigger this “no responding” bug. Some people are saying that this is due to mDNS not being broadcasted correctly, some others that this is a poor local network installation / hardware.

danerich commented 6 years ago

Having the same issue on hassio 0.79.2 on Raspberry Pi 3 64.

kirichkov commented 6 years ago

Upgrading to iOS 12, has improved things for me so far.

Dreamray commented 6 years ago

Same problems here. ha 0.78.3 on debian on hyper-v(win10), ios 12,

mbo18 commented 6 years ago

Same issue here: iPhone with iOS 12.0.1, AppleTV 4 iOS 12.0.1, HA 0.80.3 on HassOS 2.2 2018-10-23 13:36:51 DEBUG (Thread-12) [pyhap.accessory_driver] Could not send event to ('10.2.10.9', 49448), probably stale socket. I have thousand lines like this in logs (10.2.10.9 is my AppleTV) If I restart HA, it works the first time I lauch the Home app and then it stops. Home app says "No Response" for all devices except my AppleTV which is just fine.

mbo18 commented 6 years ago

I have disabled IPv6 on my ISP router and everything is working as expected now... I don't know if it's an issue between the homekit component and IPv6 or if IPv6 is not correclty supported on my ISP router

dmonagle commented 6 years ago

There is a definite bug that also causes these symptoms. There is another open issue here that refers to it:

https://github.com/home-assistant/home-assistant/issues/16692

My testing today has shown that with the dev branch of HAP python, my homekit accessory bridge runs flawlessly. With the current release, my devices go to "No Response" within minutes.

jr3us commented 6 years ago

After updating to .80.0 today, the connection between homekit and iOS worked fine for about an hour, and then started the no response message again. Also, the message about stale sockets has not changed.

dmonagle commented 6 years ago

The release with that patch in it is 0.81.0. Is that what you meant? I'm actually still having trouble with HomeKit on hassio after the upgrade. When I manually installed HAP Python previously I was able to keep connections much longer. I'm going to set up on hassbian and see what I can figure out.

jr3us commented 6 years ago

apologies. I did upgrade to.81.0. the same comments about stale sockets still apply.

cdce8p commented 6 years ago

@dmonagle Would be great if you can give an update ones you find something. Just so that I know if we can fix it or if I need to move this to the HAP-python repo.

dmonagle commented 6 years ago

@cdce8p I'm sorry, I haven't been able to figure out anything. It appears I'm running the new HAP-python, however it's still showing the same symptoms. The one difference is that when i successfully tested a working HomeKit setup, I set up a complete new database and config. With my "production" system I restore my entire config and database.

I really cannot see any reason that my config or db would cause the issue, but since I've hit a bit of a dead end, I may set up a completely empty new system on the weekend, enable homekit, test it and then build it all up from there.

cdce8p commented 6 years ago

@dmonagle I have reverted the HAP-python update for now. Can you give some more information which systems your using and how your setup is?

jr3us commented 6 years ago

@cdce8p , @dmonagle ,

I have updated to .81.4 and rebooted the RPi this morning, and after updating, Homekit/Home Assistant worked as it should for about 20 minutes. I am now getting No Response on the IOS devices(iPhone and iPad both running 12.0.1). I am also seeing stale socket messages as above, and also a couple of sockets in CLOSE_WAIT state.

If I can assist you, let me know.

Regards

Dreamray commented 5 years ago

Same problems here. ha 0.78.3 on debian on hyper-v(win10), ios 12,

I have installed HA on my win10(not on hyper-v, install python for windows first, then install HA), and deleted network setting of hyper-v. HA and homekit works very well now

dmonagle commented 5 years ago

@cdce8p Sorry about the slow response, I actually had a few days holiday. So the setup I see this problem is either raspbian or hassio. When I did testing on my Mac, I didn't see it. My production system is

0.81.5 - soon to be 0.81.6 I'm only including a few flux switches and and alarm panel for HomeKit I have 4 Apple TVs, Two Macs, 4 iPads, 2 iPhones and a HomePod on the network that are registered with HomeKit. Without fail the switches and alarm panel change to "Not Responding" within a minute of starting Home Assistant. Alerts from HomeKit still come through to the devices even when "Not Responding" is being shown. As mentioned before, I couldn't replicate this while running in a python virtual environment on my Mac.

jr3us commented 5 years ago

After uprading to 83.1 this morning, and still using the same platform as described initially, I am also seeing that I have no response more often than I have valid information in the Home app for iOS.

As @dmonagle indicated on pull request #18355, the status for devices in Home will work correctly for a few minutes, and then go No response for 4 or 5 minutes.

Side note: I had to comment out the start up automation I used above as homeassistant complained about the action: homekit.start. I also removed the autostart False so it would start up.

Regards

ASchneiderBR commented 5 years ago

Hello, I am also facing this problem, again. It was OK for the past few months, now updating to 83.1 it started all over again. Homekit works fine for the first 10 mins then goes numb, nothing updates on Home App.

ASchneiderBR commented 5 years ago

Hello @jr3us! I see you have the problem as I do. Do you use Hassio? Is it possible to revert back HAP-python to previous version? It was working great for me on 81.6. Thanks!

jr3us commented 5 years ago

i use hassbian and don't know if possible to revert back. This version does solve a problem I had regarding the close wait state on TCP connections not getting closed.

ASchneiderBR commented 5 years ago

Thanks. I will have to fix this problem that started again on version 83. Too bad because it was working flawlessly for the past few months. There is nothing significant or error on log, I have no idea were to start.

pleeja commented 5 years ago

I was also having this problem when I started with HA but for some reason it works great now and I don't know what changed..

cdce8p commented 5 years ago

@tatunts I was thinking if I should revert the latest updates to HAP-python, but although you are experiencing issues, it also fixed others. That's why I haven't so far. Unfortunately the server part that communicates with HomeKit is the one area I can't really contribute to / fix issues. It might help to open a separate issue inside the HAP-python repo, especially: https://github.com/ikalchev/HAP-python/issues At the moment that's the best I can do to help.

jr3us commented 5 years ago

I have copied my comment from earlier over to ikalchev's HAP-Python.

WhiteDogBe commented 5 years ago

I am also having issues since 83. HomeKit itself is working fine: I can control devices and everything in the Home app reflects the correct status. However, I am not receiving any push notifications. Once I restart HA though, for a few hours push notifications work again.

lingqi-su commented 5 years ago

I'm kind of having similar problems. I’'m running hassbian (0.83.3) on my raspberry pi 2 with an external usb bluetooth dongle. I bought several Xiaomi bluetooth temperature and humidity sensor and I would like to check the temperature on my iPhone 6 (iOS 9). The temperature value can be seen on hassbian.local:8123, but my iPhone keeps telling me that the sensors give no response. However, my other bluetooth devices like eq-3 thermostat can be still controlled over my iPhone 6 (iOS 9).

jr3us commented 5 years ago

@cdce8p ,@ikalchev, @xbtsw: I have found some info on differences between python3.5(used in hassbian) and python 3.6+; quoting python.org(https://docs.python.org/3/library/asyncio.html#module-asyncio) as follows for the diffs between 3.5 and 3.6:

The asyncio module has received new features, significant usability and performance improvements, and a fair amount of bug fixes. Starting with Python 3.6 the asyncio module is no longer provisional and its API is considered stable.

asyncio is used heavily in HAP-python as well as in home-assistant.

Could this be related to the problem?

cdce8p commented 5 years ago

@jr3us Unfortunately it's probably not the case. Also both use asyncio, the server part of HAP-python that connects to the devices still isn't.

warcanoid commented 5 years ago

I am also having issues since 83. HomeKit itself is working fine: I can control devices and everything in the Home app reflects the correct status. However, I am not receiving any push notifications. Once I restart HA though, for a few hours push notifications work again.

Same problem with hassio 0.83.x

ikalchev commented 5 years ago

It is possible that the thread that sends the notifications has crashed - this should be now fixed on HAP-python at dev at latest. Now we are trying to figure out if there is a further issue (see the referenced issue in HAP-python)

Another observation based on the comments I read: is it possible that HAP advertises one address, but is actually running on another? I think @xbtsw described something similar.

I am still trying to reproduce this without HA

warcanoid commented 5 years ago

@ikalchev finnaly found you, one question for you: when will be the camera component( https://github.com/ikalchev/HAP-python/issues/53 )for home kit, implemented in home assistant?

ikalchev commented 5 years ago

I implemented the camera in HAP-python 1-2 months ago, but I think you should ask @cdce8p about it’s integration into HA.

But If you want to give it a go without HA until that is ready, the README in HAP-python has some pointers.

warcanoid commented 5 years ago

Thanks, have tried this, but it is too complicated for me to set up, will wait for the implemetation.

giuseppe4 commented 5 years ago

Hi, I’m having the same issue, any update on this?

jporter-dev commented 5 years ago

I am having this issue, but I noticed it only occurs when accessing remotely. When on my LAN, everything works fine and is snappy, but when trying remotely, I get intermittent "Not Responding" which clears up 5-10 mins later. Not sure if 100% related, as the remote-only aspect makes me believe it's a networking issue.

ranunculales commented 5 years ago

Same, same; nearly 90% of my devices are HomeKit but paired to HA. I reboot Hass.io, everything seems stable, then after a few minutes, devices start reporting in that they take longer that 10 seconds and then soon after start reporting they failed to update at all. Automations and scenes degrade to the point that the system is unstable and I need to reboot it... I'm using a dedicated RPI 3B+ for HA, Homekit running through an AppleTV 4K. This happened in 0.85, but seems to be more frequent since upgrading to 0.86+.

gsotiriou commented 5 years ago

Similarly to @joshporter1 above my devices are all responding and playing nice when I'm on the same WiFi network as my HA instance. When I'm outside on my data plan all devices turn to "Unavailable" accompanied by an exclamation mark. Pressing on a device in this state does nothing. Hard pressing on it presents the message: "This accessory is unavailable. To control it when you're away from home, set up a home hub." Which is weird considering that it works fine when I'm at home.

ASchneiderBR commented 5 years ago

Which is weird considering that it works fine when I'm at home.

Hello sir. Have you setup an apple device (ipad mini, apple tv or homepod) as home hub?

You will need it in order to access outside your wifi network.

gsotiriou commented 5 years ago

Which is weird considering that it works fine when I'm at home.

Hello sir. Have you setup an apple device (ipad mini, apple tv or homepod) as home hub?

You will need it in order to access outside your wifi network.

Hello, I thought that the homekit: component should/would take care of something like that. I was under the impression that once pairing with Homekit (pin , iOS setup etc.) and putting in the proper configuration in configuration.yaml , that was all I needed to control my devices in and out of home.

Edit: Nevermind - I did some more digging and saw that (by Apple) only LAN access is allowed to the devices. I need to have an Apple device such as the one mentioned to have external access. That is bad.

Edit2: Actually this happens because home assistant is not "Homekit compatible" and thus a home hub is needed?