Is there a way to trigger another widget to re-send it's current value?
I have two toggle buttons. One button gets part of its on/off value from the other button's value. Currently I'm using "@{bank_selector}" advanced syntax in the values for the second button. But my problem is that whenever I toggle the first button, I want the second button to automatically send out it's new value based on both it's current state and the new state of the first button that I just toggled.
I was hoping I could do this with a scripting step from the first button, something that would trigger the second button to resend, but so far no luck... Perhaps I'm going about this the wrong way. Any ideas on a way to accomplish this? Thanks very much!
Hello,
I think the easiest solution is using the linkId
prop.
Set linkId
with the same name in both buttons.
If you want one to be a master and the other a slave (that means, if the master is triggered, slave will trigger too, but if slave is triggered, the master won't be).
This is how to do master/slave setup:
//master
linkId: >>buttons
//slave
linkId: <<buttons
P.S: I'm using buttons
as linkId name example, you can use any name
whenever I toggle the first button, I want the second button to automatically send out it's new value
You could call this from the first button's onValue
script:
setTimeout(()=>{
set('button_2', get('button_2'))
})
The setTimeout
wrapper ensures the second button's is reset after the first button change of value has propagated.
At first I thought your suggestion using the setTimeout wrapper was the trick I was missing, however I gave this a try, and still does not work...
I think perhaps because I've defined the advanced syntax in the "on/off" fields, instead of the "value" field, the button just won't re-evaluate the values in "on/off" unless directly touched/interacted with.
Wondering if you think this is correct behavior, or perhaps an unintentional bug of some kind? Let me know if you have any more thoughts or suggestions...
Indeed, I missed that point. It's not a bug, buttons should not resend their value when the on/off properties are changed. Do you need to change on and off ? Could not not instead use the button's script to send a message based on the value of bank_selector ?