Tag Basics for the absolute beginner

Homey uses “Tags” to save information / data that you can reuse in your flows.

A tag is a variable and can be one of the following types: String, Number, Boolean or Image.

A variable is a placeholder for a value that can be changed while the flow is running. By using variables the information that is retrieved from a device or calculated in a flow can, in the form of Tags, be used elsewhere in the same flow or in another flow.

Some variables are set by devices or functions, such as e.g. temperature in a thermometer or time in the clock function. And other variables you are able to define and edit yourself, such as the value of a countdown or a calculated mean of several temperatures.

Variables of different types may contain different information:

  • String contains characters. Numbers in a String are handled as text and not as numbers.
  • Number contains numbers. This type can be used to calculate, set, save and retrieve values.
  • Boolean can be Yes or No. Boolean is usually used to check a status, e.g. on / off or true / false.
  • Image contains an image, eg a snapshot or an album cover.

Looking at the flow cards you will notice that some cards have a small “tag” icon, clicking on that icon will bring forward a list of available tags. Based on what information the card can handle you will only see tags/variables of matching kind.

Browsing through the tag list you will see that there are many different tags and based on what devices and apps you have installed the list can become quite large. Make use of the search function.

Have fun with your tags!

4 Likes

I was looking at this today (first day with Homey) and was wondering if it’s possible to transform tags:

  • number transformations, like “tag*100”
  • substrings
  • if “text” in %tag do something

Hi Tiwas and welcome to the Homey family :smiley:

Yes, tags are carriers of the values they represent so if a tag holds number information you can use it in a calculation. eg. tag = 5, tag*5 = 25.

You can also test tags like you suggest, this is best done using the logic cards built in functions.

If you want to go wild you can install the app “Better Logic” and use the Math.js functions.

Is there any special syntax? I tried to make an incredibly annoying test with a Trådfri dimmer.
When: dimmer stopped rotating
Then: Say Dimmer rotated to Value*100

It just says that the dimmer rotatet to “0.75 times 100” or something.

You will have to do the calculation first in a separate card and save that as a variable. The say card read out exactly whats in it so if you then have the say card use that variable you get the result you expect.

Tags with numbers are in blue and have a # infront of the values.
Tags with text (string) are in green.
Tags with yes/no (boolean) are in red.
Only blue tags can be used in calculations.

1 Like

Thanks. Got it to work with better logic, but I can’t find where to declare variables for the built-in logic function. Would appreciate it it if you bear with me. Starting to see some really cool possibilities with this controller :grin:

Np, the variables for the logic card are defined under settings/logic.

1 Like

U can also convert string to number variable with the Execute mathjs expression card from better logic.

1 Like

I used this calculation in standard homey variable calculation to convert a number (in string format from MQTT) to valid dim-value for a homey dimmer:

{{round(number(<variable/tag)/254,2)}}

Where <variable/tag> is the variable or tag with string that you want to convert. In this case a value between 0-254 that converts to 0-1 with 2 decimals.

Can TAGs only be used in Pro?

Not at all, TAG’s can be used in the bridge and cloud (Homey online) versions too.

1 Like

… but, not without a premium subscription if you want to use your own variables :wink:

1 Like

Hi,
what is the maximum number of characters supported by tag system?

No clue, but this fits in a variable :upside_down_face: and I guess tags can’t hold less?