Any update on widget variables?

I'm also trying to show / hide a widget from another. This looked interesting...

Widget 1 (toggle button)

// set some condition (could be anything) and then use the set() function to update the value of the variable.
if (value === 1) {
set('variable_1', true)
} else {
set('variable_1', false)
}

Widget 2 (widget to be hidden/unhidden)

image


Thanks to @jean-emmanuel's flawless replies ...

While this answer is still valid, there is also this method since v1.9.4:

  • set the visible property to VAR{my_visibility, true}
  • change the value of that block from a button's onValue script for example:
setVar('widget_id', 'my_visibility', value === 1) 
1 Like

Can you do something similar from the custom module?

@Sub3OneDay using receive() you'll be able to change the variable's value:

  • if the variable is a widget, simply call
receive("/variable_widget_address", value)
  • if the variable is a VAR{} block:
receive("/SCRIPT", `setVar("widget_id", "var_id", value)`)

References:

2 Likes