android icon indicating copy to clipboard operation
android copied to clipboard

Multi-action grid widget implementation

Open mrdanielps opened this issue 1 year ago • 14 comments

Summary

Adds a new widget that allows the user to configure multiple actions in a grid. It's somewhat based on the existing ButtonWidget.

The widget is responsive, adjusting the number of columns based on size, and becomes scrollable when it doesn't fit all the actions.

Fixes #1193, #4549

Screenshots

Dynamic colors - light Screenshot_20241102_185606

Dynamic colors - dark Screenshot_20241102_185620

API <31 Screenshot_20241102_185635

Configuration and resizing

https://github.com/user-attachments/assets/483986b6-3774-4f0a-bb5f-01fb1fa2ab6f

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#1132

Any other notes

I've limited the scope of this PR for easier review, hence the draft status, but I will update it based on feedback. The main features I think are necessary before merging are auto-completion for icons and action data, feedback when the button is pressed, and maybe entity states.

Additionally, the existing button widget could be updated to reflect the UI changes and share some of their code. However, I didn't want to change too much considering a proposal exists to refactor this code (#4640).

mrdanielps avatar Nov 03 '24 10:11 mrdanielps

Looking great! Will the state of each item reflect in realtime? for example if the light is ON

bgoncal avatar Nov 04 '24 16:11 bgoncal

Looking great! Will the state of each item reflect in realtime? for example if the light is ON

Not yet. As mentioned in the additional notes, I limited the scope of this PR for the initial review, just to get some feedback. Although looking at the entity widget implementation, I see it should be pretty straightforward to add, so I'll look into as soon as I can.

mrdanielps avatar Nov 05 '24 16:11 mrdanielps

How often can a widget update in Android? In iOS the minimum auto-refresh is 15 minutes (besides other techniques like updating through push notification trigger)

bgoncal avatar Nov 05 '24 16:11 bgoncal

It's actually quite similar on Android. The fastest auto-refresh is 30 minutes, but AFAIK anything that wakes up the app can manually trigger an update, like broadcasts or push notifications. Widget interactions can also update it, so pressing the button will allow for the state to be updated immediately.

mrdanielps avatar Nov 05 '24 16:11 mrdanielps

The template widget updates instantly for me, there is no delay there. Our Template widget and entity state widget use a websocket subscription to update instantly.

dshokouhi avatar Nov 05 '24 16:11 dshokouhi

@dshokouhi so you keep a websocket connection all the time for the widget? 🪫😭 (We do that in iOS for local push too hahaha)

bgoncal avatar Nov 05 '24 16:11 bgoncal

so you keep a websocket connection all the time for the widget? 🪫😭

For widgets only when the screen turns on, then we stop the connection when the screen turns off. Its our best effort to keep them as up to as possible while not draining too much battery

(We do that in iOS for local push too hahaha)

yup same for local push we never stop the connection and also send a ping to the server every 30 seconds to ensure its active and current.

dshokouhi avatar Nov 05 '24 16:11 dshokouhi

Looking great! Will the state of each item reflect in realtime? for example if the light is ON

Done!

Screen_recording_20241111_005218.webm

mrdanielps avatar Nov 11 '24 08:11 mrdanielps

Gave this PR a quick test run. I think you have captured the obvious missing features like auto complete, ideally the behavior for each action should mimic the existing button widget with how fields are populated. I think that will match general user expectation. For example that widget handles when a custom integration provides incomplete action data and also when a user provides invalid action data. Looking forward to seeing this PR progress!

dshokouhi avatar Nov 11 '24 23:11 dshokouhi

ideally the behavior for each action should mimic the existing button widget with how fields are populated. I think that will match general user expectation. For example that widget handles when a custom integration provides incomplete action data and also when a user provides invalid action data.

I see, I was thinking of implementing it like the entity widget, which only takes an ID, but I'll certainly take that into account.

mrdanielps avatar Nov 13 '24 01:11 mrdanielps

There is no progress in this? 🫠

It's a really interesting improvement

vlaraort avatar Feb 21 '25 19:02 vlaraort

Wish this could be merged....

dnestico avatar Apr 22 '25 18:04 dnestico

Sorry for the long wait! I'm currently working on an improved version written in Glance that builds on the great work by @TimoPtr with the new ToDo widget.

I hope to have it ready soon enough, but for those interested, here's a sneak peek.

https://github.com/user-attachments/assets/6955deb4-ed1d-4252-aab6-43dfe7f835b5

mrdanielps avatar May 29 '25 22:05 mrdanielps

This is awesome! Also like the idea of the reload button to prevent excessive connections to check status. Can't wait!

vlaraort avatar Jun 17 '25 06:06 vlaraort