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

Add 'toggle' tap action to entity state widget #3798

Merged
merged 7 commits into from
Aug 19, 2023

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Aug 18, 2023

Summary

This PR adds a tap action option to the entity state widget, allowing users to choose between 'refresh' (current behavior) and 'toggle' (approximately, like QS/Wear) on supported entities. This should solve the most common complaint people have with the app widgets: it requires two widgets to see a state and change it, they want something like a switch.

I'm going to say this fixes #3078 - all examples given there relate to toggling entities. The tap action is set up to allow for extending it to do other actions in the future though, which is covered by #3488.

New widgets for entities that are tappable now default to this action, to match how the frontend button card also toggles/turns on/presses those entities by default.

To prevent duplicate code, the app tap/toggle action code is shared between the main app widgets, Wear shortcut tiles, and the quick settings panel tiles. The implementation is based on the pressed function used in the car interface, but without requiring an Entity object if possible (which would need to be fetched and slows down the request).

Screenshots

Tapping shows a loading indicator. It is hidden by the state changing which triggers a regular widget update.
toggle.gif

The widget configuration has a 'tap action' spinner on supported entities:

Light Dark
Entity state widget configuration with a 'Tap action: Toggle / Refresh' option, light mode Entity state widget configuration with a 'Tap action: Toggle / Refresh' option, dark mode

Link to pull request in Documentation repository

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

Any other notes

 - Toggle will stop if possible when opening/closing if supported so prefer toggle instead of open/close
 - Set the default tap action for supported entities to toggle instead of refresh
@dshokouhi
Copy link
Member

should we consider updating the widget description with this change?

@jpelgrom
Copy link
Member Author

should we consider updating the widget description with this change?

Updated. Android limits string length to 2 lines in the widget chooser so I've simplified the description to make it fit. German translators might have a difficult time ;)

Home Assistants widgets panel with entity state widget visible with description "View any entity's current state and toggle it"

# Conflicts:
#	app/src/main/java/io/homeassistant/companion/android/settings/qs/ManageTilesFragment.kt
@JBassett
Copy link
Collaborator

Just need to fix merge conflicts then good to go.

@JBassett JBassett enabled auto-merge (squash) August 19, 2023 19:04
@JBassett JBassett merged commit 7f14582 into home-assistant:master Aug 19, 2023
4 checks passed
@jpelgrom jpelgrom deleted the widget-tap-action branch August 19, 2023 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Widget with entity state and call service combined into one
3 participants