royto / logbook-card

Logbook card for Home Assistant UI Lovelace
GNU General Public License v3.0
204 stars 9 forks source link

Tap action with url example #92

Closed alanmilinovic closed 2 months ago

alanmilinovic commented 11 months ago

My sensor has "map_link" attribute that is an url leading to the google maps (https://maps.google.com/) and providing longitude and latitude in query string, showing me the exact location of my entity.

What do I need to setup in configuration so that on tap the url defined in map_link attribute is open in a new tab? Do I also need to enable history for that entity in configuration.yaml?

This is what I tried but it is not working:

tap_action:
  - action: url
    url: '{{ state_attr("sensor.220d_location", "map_link") }}'
royto commented 11 months ago

Hi, you only want to open the current value of the location or for each history ?

alanmilinovic commented 11 months ago

Hi, you only want to open the current value of the location or for each history ?

Ideally I would like to open original location not the current one.

alanmilinovic commented 11 months ago

Any idea?

royto commented 11 months ago

Hello,

i was thinking adding a type value url for attribute I would give something like

image

Maybe adding a link_labelto have a nicer link ...

alanmilinovic commented 11 months ago

Hello,

i was thinking adding a type value url for attribute I would give something like

image

Maybe adding a link_labelto have a nicer link ...

That would be amazing!

alanmilinovic commented 11 months ago

Thank you for your effort. Can you please provide some info what needs to be done from configuration point of view? Do I need to enable history as well, and if yes, how?

royto commented 11 months ago

here an example:

entity: person.julien
type: custom:logbook-card
attributes:
  - value: map_link
    type: url
    link_label: Google maps
alanmilinovic commented 11 months ago

It works very good. Thanks man, have a happy holidays.

alanmilinovic commented 11 months ago

One more thing. Is it easy to add possibility to support combined text with attributes for the value?

Like this:

entity: person.julien
type: custom:logbook-card
attributes:
  - value: 'https://maps.google.com/?q={{ latitude }},{{ longitude }}&ll={{ latitude }},{{ longitude }}&z=18'
    type: url
    link_label: Google maps
alanmilinovic commented 2 months ago

Any feedback?

royto commented 2 months ago

Hello,

this is not an easy feature. Need to dig how to implement template ...