Add 'toggle' tap action to entity state widget #3798
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The widget configuration has a 'tap action' spinner on supported entities:
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#974
Any other notes