swttt / com.swttt.homekit

Homekit for Homey
https://apps.athom.com/app/com.swttt.homekit
GNU Affero General Public License v3.0
35 stars 20 forks source link

Device State Not Updated in HomeKit #137

Closed Veldkornet closed 5 years ago

Veldkornet commented 5 years ago

HomeyKit v3.0.4 Homey v2.0.2

My device states are not being updated in HomeyKit.

For example, if a flow turned off a light, the light should be turned off in HomeKit too... but it’s not. The device still shows as being on. You then need to “turn it off” (which does nothing), and then you can turn it back on as usual.

robertklep commented 5 years ago

Does this happen for all of your devices, or for a specific device? If so, what type of device is it?

Veldkornet commented 5 years ago

Well at the moment I see the issue with my lights which are Fribaro. They are Fibaro Dimmer 2's, as well as Fibaro Wall Plug 2's.

I'll double check the other items/products, but almost all of my items are Fibaro.

robertklep commented 5 years ago

Must be v2 related, because my Fibaro Dimmer 2 works as expected in Homekit using v1.5.

I assume that the state of the devices in the Homey app is being updated properly? Also, you could try and test the current beta (v3.0.6) to see if that works better.

Veldkornet commented 5 years ago

In Homey they look to be okay indeed. I'll try 3.0.6 and let you know.

Veldkornet commented 5 years ago

Yup, same issue in 3.0.6.

I tried to look in the log, but the whole thing is empty.

robertklep commented 5 years ago

The log isn't actually implemented. I'll remove it from the settings page as it confuses people.

As for the state not updating: no idea why it doesn't work. I know that there are some issues with the Fibaro app itself, but I cannot definitively say that that's the cause of your problems.

@nhassink, do you have Fibaro devices?

Veldkornet commented 5 years ago

This won’t help identify the issue, but I don’t recall having the issue when I was using the Homey “built-in experimental HomeKit app”.

robertklep commented 5 years ago

You should be able to run both Homeykit and the built-in HK app simultaneously (each providing a separate "Woning"), if you want to check if it still works there.

nhassink commented 5 years ago

@robertklep nope sorry no fibaro here

Veldkornet commented 5 years ago

Well, I was using the “built-in” one for a while and I never noticed it (since 2.0.0 came out). It was the first thing I noticed after switched to this one.

robertklep commented 5 years ago

Since it's not inherent to Homeykit that this shouldn't work, we have to rule things out.

If it currently works with the built-in experimental HK version in your situation, but it doesn't in Homeykit, it's likely something on our end. If it also doesn't work with the experimental app, it could be something in the Fibaro app.

I'm not on v2, @nhassink doesn't have Fibaro devices, so our ability to replicate your problems are limited.

Veldkornet commented 5 years ago

Well, I can tell you that it’s not specific to Fibaro. I have the same issue with my Zipato lights, Netatmo devices, Rituals, Toon, everything as far as I can tell. Control wise, you can still turn everything off and on, but the states are never updated. Temperatures never updated. Alarms not updated, etc etc.

Can I not enable the log somehow so that I could at least see if these is an error?

robertklep commented 5 years ago

If it happens with all your devices, it seems to be something specific to either your Homey or your iOS device.

As for logging, there isn't a setting that you can enable that will show more info, but it wouldn't do much good anyway because practically speaking, everything is working (in the sense that there aren't any errors being generated, because otherwise the app would be crashing).

Have you tried the built-in experimental HK already to see if the problem occurs with that as well?

Veldkornet commented 5 years ago

The problem doesn’t happen with the “built-in” one, however that one does not have all of the device types etc and just blindly adds all of my devices, otherwise I would have used it.

robertklep commented 5 years ago

In that case, all I can suggest is to do a reset (remove the Homey "woning" from iOS, and tap "Clear HomeKit storage and start over" on the settings page).

States not being updated isn't an issue that happens for other users (at least, that I know of), so there's not much that we can debug on our end.

Veldkornet commented 5 years ago

It does seem to work initially... I have the feeling that it semi-dies somewhere along the way...

robertklep commented 5 years ago

If it does, I would suspect a Homey-core issue. When it happens next time, try and see if your Homey is using a large amount of memory. There have been issues with people seeing the Homey "app" itself taking up more and more memory, until things start failing and a reboot is required.

Veldkornet commented 5 years ago

Well I don’t know what’s normal for memory, but this is how it was when the issue started again. Just restarting the HomeKit app seems to fix it though. 25fb47af-31d2-4b00-b954-a3d7658d7415

robertklep commented 5 years ago

That memory usage seems acceptable to me.

More importantly, I had assumed that the states were never updated for you, but now I understand that you can fix that by restarting the Homeykit app? Does that mean that it works for a while and then stops working?

If that's the case: do you reboot your Homey often?

Veldkornet commented 5 years ago

Correct, it does initially work, but stops after a while. Restarting the HomeyKit app seems to fix it for a while.

I hardly ever reboot Homey, unless it installs an update.

robertklep commented 5 years ago

If it stops working, it suggests that Homey's realtime updates stop working for some reason. Once I get my Homey back, I'll have to look into that a bit closer.

Veldkornet commented 5 years ago

Any chance you've been able to have a look in more detail yet?

robertklep commented 5 years ago

No, even though I got my Homey back it's not doing much because I moved all of my home automation to Home Assistant. Not sure when (/if) I'll reinstate my Homey.

Veldkornet commented 5 years ago

I will install it via CLI and see what pops up in the error logs.

...takes a day or two to appear...

Veldkornet commented 5 years ago

Seems t be a bit of a pain getting the logs.... My Athom CLI seems to quit after about a day running with: ✖ Connection has been lost, exiting... Which is too short to reproduce the error..... will keep trying....

robertklep commented 5 years ago

I occasionally have the same problem, the CLI connection just gets dropped. With other apps too, so unrelated to Homeykit.

Veldkornet commented 5 years ago

I understand, I'm just saying, it will therefore take some time to try find anything in the logs :)

Veldkornet commented 5 years ago

Coincidentally, I now have the issue again.

In the logs for HomeyKit, I don't see any errors or anything. It just stops registering state changes... not for specific devices, but for all devices...

Turning the devices off/on in HomeKit still work, but even these are not shown in the log anymore.

robertklep commented 5 years ago

So it stops logging "State Change - ..."?

That would mean that Homey's core stops sending state change events, which is rather worrisome.

Veldkornet commented 5 years ago

Correct, it stops logging "State Change - ..." Restarting the app seems to fix it (i don't restart Homey)

robertklep commented 5 years ago

@Veldkornet when the state changes stop being logged, does it happen randomly? Or does it only happen when you make changes to Homey (specifically, adding or deleting apps or devices)?

Veldkornet commented 5 years ago

It just happens randomly, there’s no changes to devices etc that’s happening.

What I saw today, is that it logged that I opened a door, but it didn’t log closing it a few seconds later or anything after.

robertklep commented 5 years ago

Is that repeatable?

Veldkornet commented 5 years ago

Well, I haven’t figured out anything specific to trigger it, but it usually happens within a day or so of usage. Although I’ve seen that it could sometimes take a bit longer.

Veldkornet commented 5 years ago

After some testing today, my felling is that once the problem starts, even though restarting the app fixes it temporarily, it seems to occur more quickly after the app restart.

I may even say that it just keeps getting worse. A reboot of Homey seems to keep the problem away for longer...

So it may indeed be something Homey related...

Veldkornet commented 5 years ago

Andy ideas on where to look? Otherwise maybe an option for a “debug build” with a bunch of extra logging for that part?

robertklep commented 5 years ago

If the realtime updates stop working, there's not much to log. The updates themselves are all logged already, and we can't add additional logging inside Homey core.

Veldkornet commented 5 years ago

Is it normal for the memory usage by the app to jump up and down by so much?

6989E542-16B8-4B95-8AA1-32DF9193129A

robertklep commented 5 years ago

It's not excessive, and the garbage collector kicks in periodically to clean up unused memory.

Veldkornet commented 5 years ago

I checked today in the Heimdall app, and I saw there that it was still seeing the state changes for devices.

I know it not quite the same as a HomeKit app, but at least it shows that apps are still able to see the state changes of devices in Homey.

robertklep commented 5 years ago

I can't debug Homey's core. If it stops sending realtime updates for some reason, there's not much I can do about that.

Veldkornet commented 5 years ago

I understand what you're saying. But why does the Heimdall app see these changes?

Surely if Homey stopped sending the updates, then Heimdall would have the same issue?

robertklep commented 5 years ago

Each app runs in a separate process, with a separate set of communication channels to Homey. After restarting Homeykit, it starts working again because it's a new process with a new set of comm channels.

From an app developer standpoint, it doesn't make sense that without doing anything, Homey's core suddenly decides to stop sending realtime events. I have no idea what could be causing this, nor do I have any possibilities to debug this problem other than logging when a realtime event is received. When those stop being received, I can't dig any further.

Veldkornet commented 5 years ago

It appears as though I’ve fixed it! Or at the very least, this is the longest its run in a long time without breaking. Usually it broke within a day, now it's been running for a couple of days already without any issues.

I downloaded the current beta version, updated the athom-api in the app from version 2.1.140 -> 2.1.179 and installed the app via cli. Since then, I've not experienced any issues.

robertklep commented 5 years ago

That's an interesting find! Any reason why you're using 2.1.179 and not the latest (2.1.185)?

Veldkornet commented 5 years ago

Only because I didn’t know where to download it from, and 2.1.179 was easy to find from another app (Heimdall, since this was detecting the state changes). No idea why they chose that version.

So I have no idea what the changelog is even. But I’m happy to test with the latest if you put it in the beta.

robertklep commented 5 years ago

The app actually crashes immediately with 2.1.185 😖 so I'll use 2.1.179 as well, will try and upload a beta today.

robertklep commented 5 years ago

I just published v3.0.11 as a beta on the Homey app store.

Veldkornet commented 5 years ago

Great! The app was still running without any issues, and I've now installed the beta.

I'll confirm in a couple of days if it still looks good now in the beta.

Veldkornet commented 5 years ago

Still running since last week without any issues FYI

Looks to be resolved.