custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.97k stars 242 forks source link

[FR] triggers_update and javascript template #618

Closed aschor closed 1 year ago

aschor commented 2 years ago

Is your feature request related to a problem? Please describe. the "triggers_update" configuration does not accept javascript templates, according to the docs. Yet, I would like to update my card on every battery powered SENSOR update (not bynary), even if I add a new sensor in home assistant, and I cannot find a way to :

Describe the solution you'd like triggers_update would ideally interpret javascript templates an interpret some output, like a string representing a list of the entity_ids I want tu update with

Describe alternatives you've considered the only way I found is write mannually all my sensors in the list (in a template), but if I add a new battery powered sensor I'm screwed if I forget to update the list in the config

Additional context the card I'm trying to do (a cleaner view of an auto-entities): image

for now, I'm using this code ... :

        - sensor.ble_battery_xiaomi_mija_temp_hum_1
        - sensor.capteur_fenetre_parents_battery_level
        - sensor.capteur_fenetre_jade_battery_level   
        - sensor.capteur_fenetre_sdb_battery_level    
        - sensor.ble_battery_xiaomi_temp_hum_parents  
        - sensor.galaxy_s9_arnaud_niveau_de_batterie_2
        - sensor.ble_battery_a4c138b62cc4
        - sensor.smoke_rdc_battery_level
        - sensor.smoke_etage_battery_level
        - sensor.smoke_impr3d_battery_level
        - sensor.smoke_sssol_battery_level
        - sensor.tablette_p80_eea_battery_level 
roopesh commented 1 year ago

+1 from me. I am trying to hack my way around this, as I don't want to hardcode the triggers_update list. It's trivial to send it as a variable into the card.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.1.0-dev.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.1.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

adabelleleiram commented 1 month ago

Anyone get this to work? I tried it now but it still seems to be just checking the main entity for updates. Here's my code (I added the logs afterwards):

triggers_update: > [[[
const lights_in_area = variables.get_lights_in_area(this._config.name); console.log("Triggers update: " + this._config.name); console.log(lights_in_area); return lights_in_area; ]]]

This is the return value log: ['light.kitchen_counter_lights', 'light.kitchen_lights'] Yet it's still only updating when I update the state of the card entity.