home-assistant / ui-schema

A schema to define a user interface for Home Assistant.
Apache License 2.0
41 stars 6 forks source link

Homogenization of tap_action #189

Closed thomasloven closed 5 years ago

thomasloven commented 5 years ago

Different cards and elements allow different tap_actions.

The currently available actions are

Currently:

more-info toggle call-service navigate
picture-elements X X X X
(service-button) X
(state-badge)
entities X
glance X X X
entity-button X X X
light * *
picture * *
picture-entity X X X X
picture-glance 1 1 2 2
sensor X

I may have missed something. This list is just from looking at the source, not testing...

Configuration is performed by setting the value of tap_action except in the case of picture and picture-glance card where navigate is used if navigation-path is set, and more-info is used if the picture source is a camera.

Regarding call-service all picture-elements elements add entity_id: to the data passed to the service. This limits the available services.

All this (except picture, picture-glance, sensor) applies to hold_action as well.

Some of the discrepancies makes sense (light card shouldn't be expected to work any other way) but some should probably be looked over.

Related

balloob commented 5 years ago

I agree that we should homogenize (what a word). But I also think that we should wait for UI to pan out a bit more.

Then I want to see if we can make it as similar across the board as possible. Maybe even enforce it by routing it all through the same helper, so we enforce same config.

iantrich commented 5 years ago

Let's toss this in here as well: https://github.com/home-assistant/ui-schema/issues/191 once we are out of our feature freeze

thomasloven commented 5 years ago

Work is ongoing home-assistant/home-assistant-polymer#2182

thomasloven commented 5 years ago

Updated table:

more-info toggle call-service navigate long-press
picture-elements X X X X X
(service-button) X
(state-badge)
entities X
glance X X X X X
entity-button X X X X X
light X X
picture X X X X X
picture-entity X X X X X
picture-glance * * * * *
sensor X

Everything that makes sense to use long-press now uses long-press (with possible exception of entities card), and thus supports all actions. I'd call this done and will close the issue.

Edit: Note: the "glance part" of picture-glance card doesn't support all actions (as glance card does). May seem strange, but I think it makes sense, and there are ways to do things differently if you want (picture-elements).