Pairing an icon with a variable in a Supertile

Use Case: Created a Supertile using a motion detector to set a variable when it becomes active, along with a static icon.

I’m using a motion detector to display when someone is present in a room along with a STRING variable that set to tell the time room became active. When the motion detector goes inactive, I’m able to clear out the string value but don’t know how to clear out the icon with it. in other words when motion is active, display icon & variable, when inactive, display nothing.
Can this be achieved?

If you used an Icon that’s bound to a Variable, wouldn’t that solve the problem?

You could set your mappings for the variable however you see fit. I used the blank icon for when the variable was empty and a ‘Rebel’ icon for when it was not empty, but you could adapt to your needs:

image

image

Note that there is a minor quirk where if you add a state, the default is technically null, so you’ll want to add a space and then delete it for it to compare to an empty string ''. Visibly there’s no difference, but it makes a difference with how the comparison runs.

I must be a little thick headed her but I’m not having much luck Josh. How do I bind an icon to a variable? I set the STRING variable to a blank (spacebar push) which disappears as it should when following the rule I created in Rule Machine (Hubitat) to reset the STRING variable based upon my motion detector changing to INACTIVE. I set the original icon states for my motion detector (Thing) to be ‘blank’ when inactive and use a ‘chosen’ icon when active. This works standalone, but when I try to add this (Thing) into a Super Tile it still doesn’t disappear when it goes INACTIVE.

Also (unrelated?) what is an icon variable (or is it variable icon)?

Just to clarify, are you referring to Hubitat Variables rather than SharpTools Variables?

From SharpTools’s perspective, we don’t actually see the variable itself, but rather see the Variable Connector (device) that you have to create to sync things over. So if it’s a Hubitat variable, I suspect we’re actually talking about Thing’s in the SharpTools context.

Can you share some more details about how you have it setup in your Super Tile? Am I understanding correctly, that you added a new item Icon → Thing Icon, selected your Variable Connector ‘thing’ and the relevant attribute, then configured the icon states under ‘Select Icon’ in the Super Tile item editor?

There’s three different ‘Icon’ types:

  • Static Icon
  • Thing Icon
  • Variable Icon

A Static Icon is just a single static icon that you pick to display on a tile. It’s unchanging and always shows the same icon.

A Thing Icon is an icon that’s bound to a ‘thing’. You can configure the various states that you want to show different icons.

A Variable Icon is an icon that’s bound to a SharpTools variable. Much like Hubitat variables, SharpTools has a concept of variables which you can use to store text, numbers, true/false. Many people use these alongside the SharpTools Rule Engine… so like the Thing Icon, you can bind the icon to a SharpTools variable and configure the various states that you want to show different Icons.

Here’s a video showing what I was talking about. One thing to keep a close eye on is that your state mappings exactly match what you’re looking for.

For example, since my first state was " “, when I went to add another state, it used that as the baseline, so if I wasn’t looking closely, I might have missed that there was a space at the front of my " test” condition that needed to be deleted.

The process is the same for a SharpTools Variable… anywhere you chose ‘Thing’, you would choose the relevant ‘Variable’ option instead. :slight_smile:

1 Like

Yes … to clarify I’m using variables I’ve set up previously/declared in Hubitat (Hub variables). I’ll watch the video you created (thx BTW) and try to follow the steps to see if I can make this work. I think I’m pretty close :crossed_fingers:

1 Like

Still no luck getting the icon to appear/disappear along with the STRING Variable created in Hubitat (via Hub Variables).

My Config:
Sonoff Motion detector device enrolled in Hubitat - attributes are Inactive /Active
Added it to Sharptools as a Thing.
Created a hub variable in Hubitat called RoomPresence & set as a STRING
Created a variable connector (Thing) out of this variable string named RoomPresence
Created rules in Hubitat Rule Machine to set String to display a timestamp when motion becomes active; cleared out when motion goes inactive by setting orig. string to a ‘blank’ space’, then hitting backspace.
Added variable connector (RoomPresence) into SharpTools as a ‘Thing’

Created a Super Tile:
Added the STRING variable; tested it by running each rule in Hubitat being set for both active & inactive - this works no problem & displays properly in Super Tile
Added a new ‘Thing’ icon using same variable (RoomPresence), get the “?” icon
Selected gear to set the first ‘add state’ icon ‘Target’ as a ‘blank space’ then hit back space.
Selected another 2nd. ‘add state’ icon (not sure what Target to use) as the icon desired.
Note: not sure what ‘Operator’ settings to use for either blank icon (when motion is inactive) or for desired icon (when motion active) so have left both as “==”.

When I test by running the rules - I never see the image icon I chose to bind to the STRING variable I created; I do see the STRING variable properly displayed/removed as expected under test (as well in real-time when motion detector toggles between Active/Inactive.

Any other thoughts as to what I’m doing wrong?

If the Hubitat String Variable is literally a single blank space, then your condition would also need to literally be a blank space. If it’s a completely empty string (which isn’t possible in Hubitat), then it won’t match the value that’s passed over from Hubitat.

For the second condition, if you are trying to match any case where the Hubitat String Variable value is set, you could use != (not equals) and then a single space.

Edit: I wonder if the single space is tripping things up. Have you tried using a placeholder value like ‘none’, ‘no motion’, ‘inactive’ or something like that instead of the space?

Edit2: From a quick test, it looks like the blank space is problem. I see where we can tweak things to better handle the blank space and will push a hotfix out in a bit. :slight_smile:

1 Like

Hey @Mark_Britton - we just pushed an update that should resolve this. It was part of the event receiving logic that was incorrectly trying to parse a blank space, so you’ll need to change the device value in Hubitat to push a new value across to test with.

Since you don’t need an icon at all for the ‘empty’ value, you could get away with just setting a condition for ‘not empty’ as no icon is displayed by default in Super Tile mapped icons:

image

And a video demo:

Great investigative work … issue resolved! I can now create a simple, visually intuitive room occupancy monitor for my dashboard.
BTW - what tool do you use for your screen capture video clips you create as explainer vids?

I’m using ShareX, which is an open-source screenshot and video screen recording tool. :slight_smile:

1 Like