Closed Anrolosia closed 1 year ago
I strongly suggest you to reduce the code to a minimal working example (MWE) - the shortest code to demonstrate the issue. 77 lines, come on(((
Well, it's an advanced usage, of course there is some code lol. If you think 77 is to much, my dashboards are full of advanced usage, and my full template configuration yaml is about 12k of lines 😄 But sure, I edited my previous comment, and reduced the size, is it better for you now?
Weird that it only happens if you call a script in the tap_action
of a custom button card in a layout-card in an auto-entities card in a browser_mod popup called from a custom button card...
This will be a tough one to reproduce. Give me a couple of months.
Hey @thomasloven , it has nothing to do with a the tap action in the auto-entities, if I remove it, I have the same result. I will edit the code above to reflect that.
It's really linked to the fire-dom-event
and the browser_mod.popup
I'll try to figure out on my side if that can help.
I made a simple example, here is the code:
type: custom:button-card
entity: sensor.time
show_label: true
label: >
[[[ return entity.entity_id ]]]
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
data:
title: Example
content:
type: custom:auto-entities
card:
type: custom:layout-card
layout_type: grid
filter:
include:
- entity_id: sensor.date*
options:
type: custom:button-card
entity_id: this.entity_id
show_label: true
label: |
[[[ return entity.entity_id ]]]
tap_action: none
hold_action: none
double_tap_action: none
exclude: []
As you can see, I only use native sensors from HA (date, time, etc.)
Those are not good:
Because entity is linked to the main button-card, not the ones "contained" in the popup as they should
An example from the code suggest on https://github.com/custom-cards/button-card:
I think it's "only" a matter of javascript scope here, because the entity by itself is good to display the button-cards from the auto-entities result, but when we try to get this entity object in JS, it will take the main one.
Does that help with that example?
Hummm it might be linked to https://github.com/custom-cards/button-card/issues/353#issuecomment-680796779 :(
I managed to get through! It was indeed solved using templates! Thanks for your help and have a great one!
Hey @thomasloven !
I might have found a bug, I'm not sure it was raised before (Wasn't able to find anything about it yet)
I tried to use this awesome module with Button Card and your other module browser_mod BUT when I try to apply javascript templates in my button card label for example, the entity is not the one from the "object" found via auto-entities, but instead it's the entity used for the original button where the browser_mod.popup is set.
On example will be better than words:
EDIT: remove code example, see https://github.com/thomasloven/lovelace-auto-entities/issues/336#issuecomment-1385539981 for a simpler example
will not work, because
this.entity_id
is not defined if you're in a popup. I tried to replace it by[[[ return entity.entity_id ]]]
and it displays 'sensor.heating_neviweb_thermostats' :(Let me know if I can provide you more infos to help you helping me ^^
Thanks a lot!