From 21eb6a27440264856827e5958fb2e6936ce45e7b Mon Sep 17 00:00:00 2001 From: Tyler Cooper Date: Thu, 14 Aug 2025 14:38:11 -0500 Subject: [PATCH] Update matcher_compare.js --- app/blocks/matchers/matcher_compare.js | 27 +++++++++----------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/app/blocks/matchers/matcher_compare.js b/app/blocks/matchers/matcher_compare.js index 3df3d7b..4b116fb 100644 --- a/app/blocks/matchers/matcher_compare.js +++ b/app/blocks/matchers/matcher_compare.js @@ -5,51 +5,43 @@ export default { name: "Compare Numbers Matcher", colour: 224, inputsInline: true, - description: "Numerically compare the new Feed value with another number.", - + description: "Create smart triggers based on numerical sensor data and thresholds. Perfect for temperature alerts ('notify when above 80°F'), battery monitoring ('warn when below 20%'), humidity control ('turn on fan when over 60%'), or any sensor-based automation that depends on numerical comparisons.", connections: { mode: 'value', output: 'matcher' }, - template: "%OP %B", - fields: { OP: { - description: "Select a comparison to perform", + description: "Choose how to compare your feed's numerical data:", options: [ - ['=', 'EQ', "True if the two numbers are equal"], - ['\u2260', 'NEQ', "True if the two numbers are not equal"], - ['\u200F<', 'LT', "True if the Feed value is less than number B"], - ['\u200F\u2264', 'LTE', "True if the Feed value is less than or equal to number B"], - ['\u200F>', 'GT', "True if the Feed value is greater than number B"], - ['\u200F\u2265', 'GTE', "True if the Feed value is greater than or equal to number B"], + ['=', 'EQ', "Exactly equal: Triggers when feed value equals your number (e.g., button state = 1, exact temperature reading = 72.5°F). Best for digital switches and precise measurements."], + ['\u2260', 'NEQ', "Not equal: Triggers when feed value is anything other than your number (e.g., not zero, sensor reading changed from baseline). Useful for detecting changes or non-specific states."], + ['\u200F<', 'LT', "Less than: Triggers when feed value drops below your threshold (e.g., temperature < 60°F for heating alerts, battery < 15% for low power warnings)."], + ['\u200F\u2264', 'LTE', "Less than or equal: Triggers when feed value is at or below threshold (e.g., humidity ≤ 30% for dry air alerts, speed ≤ 0 for stopped condition)."], + ['\u200F>', 'GT', "Greater than: Triggers when feed value exceeds your threshold (e.g., temperature > 85°F for cooling alerts, motion count > 10 for high activity)."], + ['\u200F\u2265', 'GTE', "Greater than or equal: Triggers when feed value meets or exceeds threshold (e.g., pressure ≥ 1000 hPa for weather tracking, light level ≥ 500 for daylight detection)."], ] } }, - inputs: { B: { - description: "The value to compare with the Feed value.", + description: "Set your comparison threshold or target value. Examples: 80 for temperature alerts, 20 for battery percentage warnings, 1000 for pressure readings, or any numerical value that's meaningful for your sensor data.", check: "expression", shadow: 'io_math_number' } }, - generators: { json: (block, generator) => { const comparator = block.getFieldValue('OP'), rightExp = generator.valueToCode(block, 'B', 0) || 'null', - blockPayload = JSON.stringify({ matcherCompare: { comparator: comparator?.toLowerCase() || null, right: JSON.parse(rightExp), }, }) - return [ blockPayload, 0 ] } }, - regenerators: { json: (blockObject, helpers) => { const @@ -60,7 +52,6 @@ export default { inputs = { B: helpers.expressionToBlock(right, { shadow: 'io_math_number' }), } - return { type: 'matcher_compare', fields, inputs } } }