An expression is a piece of code which retrieves the current setting of a device capability. For example, you could create an expression to fetch the current ‘on/off’ state of a switch or the current temperature of your thermostat. You can then use the result of this call to determine whether or not your meshbot trigger runs.
Create an expressionIn this example, we will create an expression that fetches the ‘On/Off’ status of a light switch. We will then show how to select the expression in a meshbot trigger.
- Click ‘Expressions’ > ‘Add New Expression’:
- Type a name for your expression. This is the name that appears in your meshbot trigger if you select ‘Expression’.
- Best practice is to name the expression after the device capability whose state you want to monitor. For example, ‘Dimmer Light Luminance’, ‘Thermostat Temperature’ or ‘Kitchen Door Lock Status’.
- Important – Type ‘return’ at the start of the text field. You must always enter this command as a prefix in order for the expression to save correctly.
- Next, choose the device and device capability whose status you want to monitor then click ‘Add Device Reference’ to create your expression:
- This will automatically populate the text field with the code for your expression. Click ‘Create’ to save your expression:
- After saving’, your expression will be listed in the ‘Expressions’ area as shown below: