Losing Synchronization after Screen Off/Day Dream

Issue: Tiles/controls are “resetting” to their default states every time the screen either goes to DayDream or is turned off.

Device: Android 6.0.1, Nexus 7, HomeRemote 3.0.21.0.

Replication: Using the default TileTemplates and a group, turn on a light from the group. The tile changes to Accent colors, switch is toggled, etc. Allow tablet to time-out (DayDream) or turn off the screen (by the power button). Wake screen. Tiles will be reset to their default states (Foreground colors and toggles off.) Sometimes the toggles will find the correct updates and toggle properly to the “on” state after 1-5 seconds, sometimes they do not. Pressing the toggle will perform the appropriate action (if the toggle shows OFF, it will send the ON commands even if the light is already on etc). It maintains synchronization after that, until the next time the screen is off.

Notes: This could be an Android thing, not leaving the app “awake” during screen off. I’ve changed the battery optimization to “not optimize” HomeRemote but it didn’t fix it. My Nexus4 (running Android 5.something) does not have this problem. It also loses sync sometimes but not consistently like this.They’re using the same HRP file on the same screens. My devices are entirely SmartThings devices (other brands etc but all controlled via ST integration). SmartThings is showing devices synced correctly when checking on another device. This is replicated with the default DeviceBrowser tiles as well as customized tiles.

I’m turning the screen to DayDream so that I don’t get burn-in and to save the backlight LED a bit. I don’t use the panels often enough to avoid burn in naturally. Maybe there’s some other way, within HomeRemote, I could rig up a “screensaver” type thing where HomeRemote would always be in the foreground, but since my Nexus4 is working well enough with DayDream (and dims the backlight) I’d rather keep it simple.

All device connections are closed & states are reset whenever the screen turns off. When the screen turns back on the devices are reconnected & then polled for their latest status. Depending on how long the screen is off your network connection may not be available at the instant the app is resumed. The app does monitor for changes in status of the network adapters. So once it’s back online, it’ll reconnect your devices.

I have a Nexus 7 with version 6.0.1 & I ran through this several times by simply using the power button on the top right to turn the screen on & off. For me it reconnected fine every time within a few seconds. This project I have loaded on my Nexus 7 is also using SmartThings devices. I do expect there may be an occasional hiccup. Maybe 1 of the SmartThings calls times out or something like that. The fact that you are experiencing this issue every time is concerning. I don’t have DayDream installed on my Nexus 7 so I’m not sure if that is a factor.

How long are you waiting? Does it ever eventually resume connection?

Usually waiting 1-2 seconds, sometimes up to 5. It always resumes connection.

My initial explanation may have been misleading. The majority of the time, it resumes connection correctly with all tiles displaying accurate information within 1-2s. Sometimes (I can’t reproduce this consistently yet), it will resume with incorrect information (tiles at default when you turn on the screen -> Resumes -> some tiles indicate on because the light is on, some tiles indicate on even though the light has been turned off). It happens 2-3 times a day, maybe 1 out of every 5 times I use the display. Wouldn’t put too much thought into this until I figure out how to reproduce it consistently.

Is there an explanation for why my Nexus 4 (Android 5.1.1, HR 3.0.21.0, same HRP file confirmed) is instant? Regardless of if I turn the screen off or use Daydream, it seems to be in constant sync with the devices. I can turn on a light via a Google command or SmartThings switch, and when I tap my Nexus 4’s screen from Daydream, all my tiles displayed correctly. Also tried by turning the screen off completely, same thing (though I have a swipe to unlock, so maybe in the time I take to swipe it syncs?) Based on your description of how HR disconnects, this shouldn’t be possible. However, this is the ideal performance since there’s no delay when waking the screen.

I’ll keep fiddling with battery settings, maybe I can keep the connections on during Daydream/screen off somehow. No idea why the Nexus does it but the other devices don’t; perhaps android’s battery optimizations changed between versions 5 and 6. My Samsung S10e with Android 10 works the same as the Nexus 7.

Wait longer than that before giving up. It’d be helpful to know if it resumes & how long it takes to resume. Please time it if you could. Don’t wait around forever. After about 1 or 2 minutes you can give up.

I don’t know. Galaxy S9 & Nexus 7 both behave about the same. I don’t know why your Nexus 4 would behave any differently.

One other thing you can try to see if it helps, give each device its own access token. Don’t share the same token. Not sure if that’ll make any difference but it might be worth trying.

I misunderstood your waiting question; I thought you meant “how long does it take to update the statuses after turning on the screen”, which is only a few seconds.

I think I tracked down the desync problem, wasn’t anything to do with HomeRemote. Checked my IDE logs and I had another app that was screwing up SmartThings (went into loops and didn’t quit them until another action was performed), so I’m guessing the device updates and polling somehow wasn’t getting through to HomeRemote when requested. I removed that app and haven’t had the desync issue since.

I would still like to have the connections remain open and the states not reset when the screen is turned off. Is this a limitation of Android or something in how HomeRemote is intended to function?

I’ve disabled all the battery options I could find (wifi won’t sleep, no battery optimizations, etc). Doesn’t matter how long the screen is off for; the instant it’s off, HomeRemote resets the tiles. No clue what’s different that my Nexus4 is doing with the updates compared to the N7/S10e/your devices.

Note: Apparently android 6 is where they introduced “Doze”, the battery management stuff. Could be the culprit, but the above steps should have mitigated it. Not sure what else might have to be overridden.

The app doesn’t have any registered services. Its threads stop when it’s told to stop by the system. I suppose I could add an option to run the app as a service & always keep the app connections alive, even when you are using a different app or when the screen is off. I don’t think most would want or use that feature though.

Everything is disconnected during the “onStop” event during the activity life cycle. That’s when the tiles reset. The app itself does not check for battery optimizations or anything like that. The system manages all of this. Here’s some info about the Android activity lifecycle to help you better understand how that works.


I think it would be useful for anybody who uses the app on a wall-mounted tablet or similar. Does everyone else just run their displays always-on? Or just deal with the 1-2s delay to update the interface?

I use mine kind of like light switches, since half of my devices are bulbs (house is old, and a rental; buying and installing no-neutral switches would have gotten expensive very quickly). Means the 1-2s delay is noticed every time, and if you tap it too quickly (before it updates) it sometimes gives the wrong input and gets confused for a moment until it catches up.

I’ll try not to speak for all, but it also kind of depends on the environment & devices being used. For a locally connected hub that delay isn’t nearly as noticeable. SmartThings has to connect through the cloud which can take a second or 2. For something local, you are usually in the milliseconds range & barely have time to even see the transition.

Unfortunately most of my devices are cloud-based, or have cloud-based integrations with ST. I think it takes some planning (and usually money) to stick to entirely local devices when things like Tuya devices are dirt cheap. I have a pair of Hue bulbs I can connect that should run locally, see if it makes a difference on my devices.

For now I customized the Tasker Clock Screensaver to replace Daydream. It covers the screen with a moving clock to minimize burn-in, but still allows the screen to stay on in Android’s eyes. This means HomeRemote is never unloaded, so there’s no refreshing and everything maintains the tile statuses.

1 Like