Use variables in triggers_update
See original GitHub issueIs your feature request related to a problem? Please describe. The triggers_update feature is great, but it only works with static text. I have some fields that I define as variables for a template, but I have to list them again under triggers_update to get the card to update with them.
Describe the solution you’d like Process variables in the triggers_update field. Listing the fields is great, but let me reference the variable, as well.
Describe alternatives you’ve considered The status quo works, but is redundant.
Additional context Here’s the template I’m working with:
control_motion:
variables:
motion_boolean: "input_boolean.null"
double_tap_action:
action: call-service
service: input_boolean.toggle
service_data:
entity_id: >
[[[ return variables.motion_boolean ]]]
custom_fields:
motion: >
[[[
if (states[variables.motion_boolean].state == 'on') {
return '<ha-icon icon="mdi:motion-sensor"></ha-icon>';
} else {
return '<ha-icon icon="mdi:motion-sensor-off"></ha-icon>';
}
]]]
In my UI code, I have to list the motion_boolean
field twice, both in variables
and in triggers_update
:
- entity: light.stairs_hallway
type: custom:button-card
name: Stairs/Hallway Lights
template:
- general
- inside
- control_motion
variables:
motion_boolean: input_boolean.motion_light_hall
triggers_update:
- input_boolean.motion_light_hall
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7
Top Results From Across the Web
How To Set Variables in MySQL Update Trigger
CREATE TRIGGER Update_estimate_from_line_items AFTER UPDATE ON estimate_line_items FOR EACH ROW BEGIN -- variable declarations DECLARE ...
Read more >Trigger variables (PL/SQL) - IBM
Trigger variables (PL/SQL) · NEW is a pseudo-record name that refers to the new table row for insert and update operations in row-level...
Read more >Local Variable in UPDATE() T-SQL Trigger Function
I am trying to use the UPDATE() Trigger Function for local variable @fieldname. The goal is this way I am only comparing the ......
Read more >SQL Server trigger with variable - YouTube
For queries contact on gamerstrings20@gmail.comGOALTER TRIGGER [dbo].[trigger1] ON [dbo].[tab1]for insertASdeclare @counts intBEGINselect ...
Read more >Trigger Context Variables | Apex Developer Guide
Trigger Context Variables ; old, Returns a list of the old versions of the sObject records. This sObject list is only available in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I’d like to add my 2 cents: I do an intensive use of templates in my lovelace, working extremely with variables. I have button cards with 5 icons (just icons, not nested cards) inside, each with its logics related to a specific sensor that can be built starting from the main entity of the card. So, adding these sensors as triggers in the definition of the card means loosing power of template itself. In this case, js in triggers sections may help…
I would just like to add that this would be very useful, even if just on the initial build of the card. Here’s my example. I have a switch that reports power usage as well. However this is all done thru tasmota and when the switch turns on and off, it takes a predefined period of time for the power usage to update (defined in teleperiod in tasmota). So if i turn the switch on as an example, the power updates in say 10-15 seconds… but by that the time state has already changed on the main entity (the switch itself) so the button card never catches the power usage update. I have the power usage displayed on the button itself. In addition, the power usage is represented by a sensor entity and i pass this entity as a button-card variable in my yaml config. Just like below:
So what happens here is switch goes on, but power still says 0W… but when i click the switch off, the button card updates to 13W, even tho the swithc is now off, because it takes ‘teleperiod’ of time to update the power usage.
What i wanted to do is use the variables defined in the button card to be the ‘triggers_update’ so when they change, the card updates. However unfortunately i cannot get it to work for reasons for which i now understand (templating a list).
This is my template config (or some of it anyway:
This doesnt work but you can get the idea of what id like to accomplish. That would be my use case anyway… hope that all makes sense.