question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New widget type: double-button with visible state

See original GitHub issue

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

I want to be able to do some actions very quickly:

  • Turn a light on or off.
  • Make a light dimmer or brighter.
  • Change the volume of a media player
  • etc.

The current way to do those actions is:

  1. Open the Home Assistant app.
  2. Wait for the splash screen to go away (the one with the white background; which kind hurts my eyes as everything else is dark on my device, but that’s a different issue).
  3. Wait for the Lovelace webview to load.
  4. Navigate to the input I need (either a different sidebar item, and/or a different tab, and/or scroll down to the card).
  5. Finally, interact with the input.

Describe the solution you’d like

If you notice, most actions have a duality: turn on/off, change the volume up/down, dim the light darker/lighter, make the white balance colder/warmer, roll the blinds up/down…

Thus, I propose a new widget type that contains two buttons, and an optional visible state. Look at this ASCII Art mockup with a few examples (slightly broken because unicode/emoji characters are not the same width as other characters):

.-------.   .-------.   .-------.   .-----.
|   ⇧   |   |   ⏽   |   |   🔆   |   |  🔊  |
| Blind |   | Swtch |   |  Lamp |   | 42% |
|   ⇩   |   |   ⭘   |   |   🔅   |   |  🔉  |
'-------'   '-------'   '-------'   '-----'

The widget can have either two or three interactive areas:

  • The top half (or top third) will call a service (e.g. light.turn_on).
  • The bottom half (or bottom third) will call another service (bonus points for automatically suggesting the complementary service in the UI).
  • The middle third can update the visible state upon touch. That way, the user can refresh the visible state manually (similar to the current template widget).
    • This state should be automatically updated a couple of seconds after the service was called if the other thirds were tapped.
    • If this state is static (i.e. a literal string), then the middle third could be ignored, and thus the interactive area could be changed to halves instead of thirds. This can be helpful if the user prefers a very compact-size widget.

Bonus idea: I know some widgets have scrolling support (e.g. the calendar widget from your phone calendar). Thus, it’s possible to detect up/down swipes in a widget. Then, instead of just tapping (which is a binary action), we could have some analog-ish interaction. The user could swipe up/down and then the amount of brightness/volume changed would be proportional to the length of the swipe. This could be implemented by repeatedly calling the up/down services for each “Y” amount of finger movement. In other words, it would behave similarly as an incremental encoder.

Describe alternatives you’ve considered, if any

My alternative, so far, is to have many widgets. Look at this screenshot:

image

And the same widgets, after I rotate my device to landscape orientation:

image

There are four button widgets, plus one template widget in the middle. Five widgets in total. Their paddings were removed (a feature of the Nova Launcher), and they were resized to the minimum “usable” size. There are many issues with my current solution:

  • Too many widgets (4+1).
  • Button widgets can’t have dynamic (template-based) label, forcing me to use a template widget.
  • Template widgets can’t have any interaction, forcing me to use button widgets.
  • Tapping on buttons doesn’t update the template; I have to remember to tap the template as well.
  • Button widgets can’t have an empty label (i.e., if the label is an empty string, there is a wasted “empty” space reserved for the label).
  • The label for up/down actions is duplicated (because button widgets must have a label).

Additional context

Somewhat related issues:

Further refactoring idea

If we take a step back, this widget that I’m suggesting is a superset of the current widgets. Thus, we could imagine a future where we have only one very flexible widget type, and that type contains multiple pieces:

  • If it contains only one “button” piece, then it emulates the current button widget.
  • If it contains only one “template” piece, then it emulates the current template widget.
  • If it contains a button piece, followed by a template piece, followed by another button piece; then it emulates the ASCII-Art mockup I described above.
  • This also means we could have a 3-button widget: [volume up, mute, volume down] or [previous, play/pause, next] or [brighter, toggle, darker]
  • This also means the user could have some arbitrary presets: set brightness to [100%, 75%, 50%, 25%, 1%]

So, this new flexible widget idea would be one widget to rule them all. Or almost. And I understand it takes quite some work to make it usable (specially building the UI, I know UIs are surprisingly time-consuming to build).

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
KBerstenecommented, Oct 25, 2020

@denilsonsa Check out the PR I have open. The only thing I think I don’t have that you have suggested here is a 3-button widget, though I have already created a media player widget that would cover your previous/playpause/next use case.

0reactions
Minckacommented, Jan 18, 2022

Thanks to the latest update with websockets support and instant status update, this kind of feature, or even more simple ideas like #402 would make even more sense. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make icon button overlapping container widgets in ...
My first approach is using Stack which contain Positioned widgets (for the double button) and Container (for the other things). But, the ...
Read more >
Solved: How to add button to widget - ServiceNow Community
Solved: I want to add a button named 'New' to my custom widget which will be seen at top right corner After clicking...
Read more >
Binding to Events (Mastering Perl/Tk)
A widget's visibility has changed. Of all these event types, most of the time you'll only deal with ButtonPress, ButtonRelease, Destroy, Enter, KeyPress, ......
Read more >
Solved: Switch Visibility with togglebutton - PTC Community
Solved: Hello, I want to switch the visibility option from a label and a slider in a Mashup When the button is in...
Read more >
Create UI using Tkinter in Python - TutorialsTeacher
All Tkinter widget classes are inherited from the Widget class. ... Its ON state is displayed by the tick mark in the box...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found