auths
objectDetermines if you are checking the current temperature or weather conditions.
Determines if the workflow continues. For temperature checks, any setting is ok, but most likely you will use less than or greater than. For weather checks, only "equals" makes sense.
This is the actual value to use when checking. For temperatures it should be a number (temperature in Fahrenheit). For weather checks, the type of weather condition.
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
let check = params.type;
let condition = params.condition;
let value = params.value;
console.log('check', check, 'condition', condition, 'value', value);
if(check === 'temperature') {
let temp = steps.trigger.event.observations.location[0].observation[0].temperature;
//convert temp to F
let tempF = Math.floor((temp * 9/5) + 32);
value = parseInt(value, 10);
if(condition === 'less than or equal' && tempF > value) $end('Temperature not low enough');
if(condition === 'greater than or equal' && tempF < value) $end('Temperature not high enough');
if(condition === 'equal' && tempF !== value) $end('Temperature not equal');
// export the temp
this.temperature = tempF;
} else {
// assume condition is equal as nothing else makes sense
let weather = steps.trigger.event.observations.location[0].observation[0].skyDescription.toLowerCase();
// lowercase value too
value == value.toLowerCase();
if(value !== weather) $end(`Condition ${weather} not equal to ${value}`);
// export the weather
this.weather = weather;
}