Merge pull request #11 from adafruit/tylerdcooper-patch-7

docs: data matching trigger block
This commit is contained in:
Loren Norman 2025-08-11 15:54:28 -04:00 committed by GitHub
commit 62869113ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,22 +5,18 @@ export default {
name: "Data Matching", name: "Data Matching",
colour: 30, colour: 30,
inputsInline: true, inputsInline: true,
description: "Run this Action when the specified Feed receives data that matches the specified condition.", description: "The most common trigger type - runs your Action immediately whenever new data arrives at a feed that meets your specified condition. Perfect for real-time responses like 'send alert when temperature exceeds 85°F', 'turn on lights when motion detected', or 'notify me when battery drops below 20%'. This trigger fires every single time the condition is met.",
connections: { connections: {
mode: "statement", mode: "statement",
output: "trigger", output: "trigger",
next: "trigger" next: "trigger"
}, },
mixins: ['replaceDropdownOptions'], mixins: ['replaceDropdownOptions'],
extensions: [ "populateFeedDropdown" ], extensions: [ "populateFeedDropdown" ],
template: "When %FEED_KEY gets data matching: %MATCHER", template: "When %FEED_KEY gets data matching: %MATCHER",
inputs: { inputs: {
MATCHER: { MATCHER: {
description: "Attach a Matcher block to compare against new Feed values", description: "Define the condition that incoming data must meet to trigger this Action. Examples: 'equals 1' (for button presses), 'greater than 80' (for temperature alerts), 'contains \"motion\"' (for text matching), or 'any value' (triggers on every data point regardless of value).",
check: 'matcher', check: 'matcher',
shadow: { shadow: {
type: 'matcher_compare', type: 'matcher_compare',
@ -30,16 +26,14 @@ export default {
} }
} }
}, },
fields: { fields: {
FEED_KEY: { FEED_KEY: {
description: "Select the Feed to watch for new data.", description: "Choose which feed to monitor for new incoming data. Every time fresh data arrives at this feed, it will be tested against your matcher condition.",
options: [ options: [
[ "Loading Feeds...", ""] [ "Loading Feeds...", ""]
] ]
} }
}, },
generators: { generators: {
json: (block, generator) => { json: (block, generator) => {
const const
@ -50,15 +44,12 @@ export default {
feed, matcher feed, matcher
} }
}) })
return payload return payload
} }
}, },
regenerators: { regenerators: {
json: (blockObject, helpers) => { json: (blockObject, helpers) => {
const payload = blockObject.whenDataMatching const payload = blockObject.whenDataMatching
return { return {
type: "when_data_matching", type: "when_data_matching",
fields: { fields: {