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

WearOS: Add option to refresh template tile when in view #4007

Closed
jeremysherriff opened this issue Nov 9, 2023 · 11 comments · Fixed by #4185
Closed

WearOS: Add option to refresh template tile when in view #4007

jeremysherriff opened this issue Nov 9, 2023 · 11 comments · Fixed by #4185
Labels
enhancement New feature or request Wear OS

Comments

@jeremysherriff
Copy link

jeremysherriff commented Nov 9, 2023

Is your feature request related to a problem? Please describe.

My Template tile is usually out of date when I scroll to it.
Existing refresh interval options for template tiles are quite coarse, but making them more aggressive could be a bad thing (battery life, data usage etc)

Describe the solution you'd like

Add a new command_ notification that triggers a refresh of the template tile.
As well as (or instead of) setting a refresh interval for my template tile, I could then refresh it using an automation that leverages the existing notification channel.
This will allow for pseudo-real time updates of the template tile, without using a high refresh interval. It would be similar to the request_location_update command notification, in that the update is not guaranteed and frequent calls may be detrimental to battery life. See the warnings here.

Describe alternatives you've considered, if any

  • Refresh of the template tile could be included as part of command_update_sensors but this seems a poor fit.
  • Expose the template tile refresh intent so that advanced users can call it using command_broadcast_intent or command_activity
  • If refreshing the template tile is already possible using a command_broadcast_intent or command_activity, please add to a relevant part of the Companion docs?

Additional context

If this feature may complicate or be complicated by #3697

@jeremysherriff jeremysherriff added the enhancement New feature or request label Nov 9, 2023
@dshokouhi
Copy link
Member

I don't think this is possible outside of the app as all we can set is the freshness interval which is user controlled here. Have you tried moving the template tile to be closer to the watchface so it updates faster? My camera tile closest to the watchface is always up to date but not the ones next to it.

@dshokouhi
Copy link
Member

Regarding the refresh intervals. Data usage shouldn't be of any concern for a template tile is only text. For battery only you can see if changing the interval will be detrimental, depending on your usage it may not be. I have the interactive sensor enabled on my watch so a network call gets made anytime my screen turns on and my battery life is not impacted by that.

@jeremysherriff
Copy link
Author

Thanks for the thoughts.

My specific use case is a template tile that shows the state of my garage door. I have this because my garage door remote often doesn't trigger, and sometimes when I think I've closed the door I find that it is still open when I check (via HA).

In my use-case, a 5-minute refresh interval is too aggressive for most of the time, but when the garage does actually open/close I would like the template tile to almost-immediately reflect the state. A 1-minute interval is massively over-aggressive when there is likely to be only 4 or 6 state changes across the course of any 24 hour period. I am looking for a way to trigger the template tile refresh when the state of the door changes.

Another potential option is for the template tile to trigger a refresh automatically on coming into view - would that be an option? It would seem sensible that many/most users would want the template tile to be up-to-date upon scrolling onto it. If indeed this is possible, this "on visible" update could either be an optional addition to the refresh interval (eg a tick-box), or could be part of the refresh interval selection list, like this:

  • Manual
  • On viewing tile
  • 1 minute
  • 2 minutes
  • 5 minutes
  • 10 minutes
  • etc

@dshokouhi
Copy link
Member

unfortunately you'll never be able to get the template tile to reflect the state of the entity, lots of discussion about keeping tiles up to date here

Also adding an option for "On viewing tile" won't work as the app doesnt get notified about that. Tiles are meant to be limited and cant be kept as up to date as HA users would like.

Alternatively you should consider adding the entity as a entity state complication, complications update anytime the screen turns on because they are allowed to, that sounds like a better fit for your use case.

https://companion.home-assistant.io/docs/wear-os/#complications

@dshokouhi
Copy link
Member

Also adding an option for "On viewing tile" won't work as the app doesnt get notified about that.

ok I stand corrected, after speaking with @jpelgrom we have found that there is a way we can possibly update the tile when in view but we need to test and see how things work.

https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileService?hl=en#onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent)

If this works I personally don't think it should be included as part of the refresh interval but we should update the tiles by default when in view

@jpelgrom
Copy link
Member

jpelgrom commented Nov 9, 2023

If this works I personally don't think it should be included as part of the refresh interval but we should update the tiles by default when in view

Unless you set the refresh interval to never, in which case it wouldn't make sense for it to automatically refresh when viewed

@dshokouhi
Copy link
Member

If this works I personally don't think it should be included as part of the refresh interval but we should update the tiles by default when in view

Unless you set the refresh interval to never, in which case it wouldn't make sense for it to automatically refresh when viewed

ah yes good point, Manual should indeed remain a manual :)

So with that logic then we should probably also add an option to only update when viewed? I can see that being useful too, why have a tile update if you are not looking at it, then again not using a freshness interval will result in slower updates 🤔

@jeremysherriff
Copy link
Author

This is sounding really good, not sure about the difficulty to code such a feature but from my point of view it meets my needs and seems a logical improvement of the overall Template Tile functionality.

ah yes good point, Manual should indeed remain a manual :)

So with that logic then we should probably also add an option to only update when viewed? I can see that being useful too, why have a tile update if you are not looking at it, then again not using a freshness interval will result in slower updates 🤔

My proposed list of refresh intervals above sounds like it meets that:

  • Manual
  • On viewing tile
  • 1 minute
  • 2 minutes
  • 5 minutes
  • 10 minutes
  • etc

So just to confirm, the outcome of choosing "15 minutes" would be a background refresh every 15 minutes, plus a "foreground" refresh when the Tile is scrolled into view?

@dshokouhi
Copy link
Member

So just to confirm, the outcome of choosing "15 minutes" would be a background refresh every 15 minutes, plus a "foreground" refresh when the Tile is scrolled into view?

yes thats how it should work however I think each watch is going to have slightly different behavior. Official docs on this interval

Take this for example my Pixel Watch has 3 camera tiles all to the left of the watchface all 3 have the same 1 hour refresh interval selected.

Just about every time I go to the first camera tile to the left its always up to date unless I check more in the hour. The second tile has a 50% chance of being up to date or updating when I scroll into view. The third tile usually updates a few seconds after scrolling into view but sometimes I need to hit the manual refresh button if i feel its taking too long. Now how old can the image be you might wonder? it can be HOURS it can be night time and I see a photo from the morning or vice versa so its definitely not updating as you would expect.

My template tile is 3 tiles over to the right, usually out of date but updates as soon as I scroll into view. I have the template tile refresh interval also set to 1 hour.

So IMO the delayed update when tile is scrolled into view will probably have the same effect in my own use case as the watch is probably delayed in updating until the screen comes on when a freshness interval has lapsed. Whats most interesting is that the first tile fully respects the interval while the others wait until its in view.

@jeremysherriff
Copy link
Author

Interesting background information. I typed out a long response musing about different angles of it, but that would send the conversation off topic 😄

I had a quick search of the Wear tile code and don't see the onTileEnterEvent event being employed for the camera tiles. Maybe that could help "solve" that difference in observed behaviour?

@dshokouhi
Copy link
Member

I had a quick search of the Wear tile code and don't see the onTileEnterEvent event being employed for the camera tiles. Maybe that could help "solve" that difference in observed behaviour?

we don't use this event in any of our tiles, camera tile and template tile have the same logic here actually and in my experience I see the same behavior. The watch controls when things are updated according to the refresh interval. Adding this event will only increase the frequency in updates when the tile is scrolled into view, it won't mean the tile will be kept more up to date when not in view.

Set your freshness interval to 1 minute and you will probably see the same delays mentioned, tile will appear out of date momentarily then without any interaction it will update.

@dshokouhi dshokouhi changed the title WearOS: Add a command notification to refresh template tile WearOS: Add option to refresh template tile when in view Nov 9, 2023
@jpelgrom jpelgrom linked a pull request Feb 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Wear OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants