Homey Community Forum

The Saga of the Mighty Philips Hue, the Homey Killer [transient disconnects]

The Problem

It started when I installed Philips Hue app for the first time (about a year ago): The Homey would sometimes lose connection to the network.
Symptoms:

  • Mobile app would not work, displaying instead “Unable to connect” error message. This would typically resolve itself within 10 seconds
  • If I’m using the app to modify a Flow and the disconnect happens, I lose my work and have to start it from scratch.
  • Scheduled triggers don’t fire when this condition happens. E.g. my morning alarm is no longer guaranteed to ring.

These disconnects happen often enough to make my system unreliable. Ironically, as Philips Hue is probably most popular smart home product on the market, so the fact that this one app makes my entire Homey system broken is a big deal.

The problem only happened when Philips Hue app was installed, so I removed it and tried reinstalling every now and then, considering that the problem is localized within the app.

One year later

I reinstalled Philips Hue app every now and then, hoping the problem would be fixed in a newer version. After the problem was not solved within a year, I contacted Homey Support.
What we learnt:

  • The problem is really Philips Hue app specific, no other app experiences it.
  • It happens even if Hue is the only app installed on my Homey
  • CPU/memory usage is OK, and my Hue set up (4 lights) should not represent significant load for it.
  • Changing power supply to a more powerful one doesn’t solve the problem.
  • Disconnects are fairly short-lived, they happen quite often to be a nuisance, yet without any clear pattern
  • Nightly Homey restart doesn’t help.

Homey support promised to pass the ticket further to dev team, and I haven’t heard from then ever since (for 5 months)

Chapter 2

Well, I REALLY wanted to automate my Philips lights. So I’ve written an own app for it :smile:
Background: I’m a .NET developer, primarily with backend expertise. My Node.js experience is somewhat limited, so newbie mistakes are not unexpected.

Initially, it worked flawlessly. Lights registration, turn on/off, brightness changes, I even created a flow to set a scene on a light group - it all worked well and stable. Then I needed to add light state sync, so that when I turn a lamp on with my wall switch, the Homey system would pick it up - so I implemented light state polling.

And so it was broken again.

The very same symptoms: disconnects, non-working flows, unreliable alarm clock - they all are back.
What it this thing? Can’t Homey handle one REST call every 5 seconds? Am I doing something wrong? At this point I’m crestfallen and only hope the community’s eyes would help me see what I don’t.

GitHub: GitHub - ArtemSyromiatnikov/homey_hue: A simple Homey app for Philips Hue integration

A screenshot: how the disconnect looks during app debug

1 Like

There’s been a lot of networking weirdness with Homey for years now, especially with permanent connections (things like websockets and also the CLI client console connection) getting disconnected for no apparent reason.

To me, it sounds like there’s something blocking the core Homey process. Assuming that it isn’t something silly like obviously-blocking JS code, perhaps lock contention of some sort; it might well be deep into kernel territory where the kernel gets blocked on I/O or whatever. Or possibly a misconfiguration, like a limited number of available file descriptors.

However, Homey is a big white black box. There’s no way for app developers to properly debug this issue. All we can do is try and work around it, and report it to Athom (who, typically, are “unable to reproduce the issue” and henceforth consider it a fluke that doesn’t need further investigation).

One remark regarding your code (I’ve only glanced over it): I would suggest not using setInterval but setTimeout (so start a new timeout at the end of _onPoll). Because if, for some reason, _onPoll takes longer than the interval, it may start a new polling operation when the previous hasn’t finished yet.

2 Likes

Thanks for your response Robert, and having a glance at my code.
It’s really a bit frustrating to see that this problem might lie on a deeper level. As an app developer I’d love to work with the platform I can rely upon.
Thanks for the setTimeout() tip, I’ll give it a try! I was also considering implementing a custom polling scheduler as a way to reduce amount of web requests and work around the problem this way. Something like “poll more often in the morning and evening hours, more seldom at night; more often directly after state change; decrease polling interval rate exponentially, etc, etc”. But wanted to make sure first that I’m not making any obvious mistakes (like allocating/releasing resources and such)

However, Homey is a big white black box.

Technically, its a white black sphere box :grinning_face_with_smiling_eyes:

1 Like

Just to be clear about it, the app that you have issues with is the Philips Hue app from Athom… right? Eg. the one that talks to Philips Hue Hub/Gateways.

1 Like

Yes, the Hub app (both the one from Athom, and the one he wrote himself).

1 Like

Correct, the Philips Hue app by Athom B.V. (nl.philips.hue)

By the way, I’ve found earlier versions of this app on github yesterday, and it seems I use very similar approach for polling Hue bridge API. There’s the common denominator…