If there a way to change the style for a tile by a rule or the value of a variable which is not associated to the tile.
I’m looking to “grey out” the volume controls for my home audio system when the mute is pressed.
I could do it by holding onto the current volume level in a variable when Mute is pressed, set tile volume variable to 0 and have the volume tile use a “greyed out style” when the volume is 0.
Then when unmute is pressed i could reset the volume to the held value and the style for the volume tile will get adjusted correctly. A little wonky…
If I do that, I still have to a couple tiles I set up which simple execute a rule to set the volume to a predefined level. For those tiles there is no real control I can execute to change the style state.
Is there a way to access tiles by rules ?
@Edward_Brown, no you cannot change the style based on the attribute/variable not associated with that specific tile. However, you can create a
isMuted and add this variable via “Variable Tile” to the dashboard, and configure its tap action to run the rule to restore the volume. Then you can style this Variable Tile based on
isMute variable value, and use a rule to update this variable’s value based on the volume setting or if the mute is pressed accordingly.
Yeah - that’s basically what I was saying.
I have a BOOL variable which is toggle on/off by a variable tile for the BOOL . When the bool is changed it fires an event/rule and the volume is muted/unmuted and this tiles style changes.
But my tiles to set a predefined value (trigger rule to set vol = 40 when tile is pressed) has style no choices associated to it. So I don’t have the option to grey it out by a value.
I think i can do it using more variables and rules, but seems to get complex.
I see that we can code some JS scripts inside of tiles. Maybe that’s the route I should take, seems like a lot of extra work though
One other question - can we just get a trigger of “changed” and not "Is changed and = X’. I just want to know when a state changes so I can trigger things, doesn’t matter if it changes up/down/equal.
Depending on your need, you could use the same Boolean variable for all of the tiles with custom actions so you get the underlying styling functionality.
Then use the $.runRule() hyperlink syntax to customize each tile and which rule it calls for sending the command. (Potentially even using a single rule and sending a parameter which you use in an if condition to determine what to do)
As @josh mentioned, you don’t need to create multiple variables. See the screenshot below for example that I add the same variable
isMuted multiple times to the dashboard, and configure their tap action to trigger different rules using the
$.runRule() syntax, or passing different parameter values to the same rule to run different actions in the same rule.
To trigger the rule when the attribute changes no matter what value it changes to you can do something like the following. Since any of the trigger condition matches will kick off the rule, you can add triggers of “equal” and “not equal” in the same time, so no matter what state it changes to, it will match either one of the conditions. Or if the attribute value type is
NUMBER, I usually use trigger
is greater or equal to 0 to make sure the rule gets trigger no matter what value it changes to when I know the value is always gonna be 0 or above.
Oh… I was unaware of the open hyperlink and that $.runRule.
I am doing the same thing you are for firing a rule. If variable has change and > -1 for example.
I’ll have to look into what else you can do with the open hyperlink. I thought it was literally just used for typical url things.
I as just starting to make BOOLs for that same reason!