From c6571763a08e2d1466c03be330849afcbaa82d04 Mon Sep 17 00:00:00 2001 From: Tyler Cooper Date: Thu, 14 Aug 2025 14:44:46 -0500 Subject: [PATCH 1/2] Update operation.js --- app/blocks/logic/operation.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/app/blocks/logic/operation.js b/app/blocks/logic/operation.js index 1b2eca9..580dbc0 100644 --- a/app/blocks/logic/operation.js +++ b/app/blocks/logic/operation.js @@ -5,46 +5,39 @@ export default { name: "Logic Operation", inputsInline: true, colour: 60, - description: "Perform the specifed boolean logic operation on two operands.", - + description: "Combine multiple conditions to create sophisticated decision logic in your Actions. Perfect for complex automation like 'if temperature is high AND humidity is low', 'if motion detected OR door opened', or any scenario where you need multiple criteria to work together. Essential for building smart, multi-factor IoT control systems.", connections: { mode: "value", output: "expression", }, - template: `%A %OP %B`, - inputs: { A: { - description: "A block diagram that will be resolved to a truthy/falsy value", + description: "The first condition to evaluate (left side). Connect comparison blocks, sensor checks, or any logic that results in true/false. Examples: 'temperature > 80', 'door equals open', or 'battery < 20%'.", check: "expression", shadow: 'io_logic_boolean' }, - B: { - description: "A block diagram that will be resolved to a truthy/falsy value", + description: "The second condition to evaluate (right side). Connect another comparison, sensor check, or boolean logic. Examples: 'humidity > 60%', 'motion detected', or 'time between 9 AM and 5 PM'.", check: "expression", shadow: 'io_logic_boolean' } }, - fields: { OP: { - description: "Select the logic operation to perform on the inputs:", + description: "Choose how to combine your two conditions:", options: [ - ['and', 'AND', "Resolve `true` if both operands are true, otherwise `false`."], - ['or', 'OR', "Resolve `true` if either or both operands are true, otherwise `false`."], + ['and', 'AND', "Both conditions must be true: Returns true only when BOTH inputs are true (e.g., 'temperature > 80 AND humidity < 30' for hot and dry conditions requiring both criteria simultaneously)."], + ['or', 'OR', "Either condition can be true: Returns true when AT LEAST ONE input is true (e.g., 'motion detected OR door opened' triggers on any activity, 'battery < 10% OR offline > 1 hour' for multiple alert conditions)."], ] } }, - generators: { json: (block, generator) => { const operator = block.getFieldValue('OP'), leftExp = generator.valueToCode(block, 'A', 0) || null, rightExp = generator.valueToCode(block, 'B', 0) || null, - blockPayload = JSON.stringify({ logic: { left: JSON.parse(leftExp), @@ -52,11 +45,9 @@ export default { right: JSON.parse(rightExp), }, }) - return [ blockPayload, 0 ] } }, - regenerators: { json: (blockObject, helpers) => { const @@ -64,11 +55,10 @@ export default { fields = { OP: comparator?.toUpperCase() }, - inputs = { + inputs: { A: helpers.expressionToBlock(left, { shadow: 'io_logic_boolean' }), B: helpers.expressionToBlock(right, { shadow: 'io_logic_boolean' }), } - return { type: 'io_logic_operation', fields, inputs } } } From a03ca05cc8e0a64ca899d34909f33e326145689d Mon Sep 17 00:00:00 2001 From: Loren Norman Date: Fri, 15 Aug 2025 12:20:56 -0400 Subject: [PATCH 2/2] code fix --- app/blocks/logic/operation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/blocks/logic/operation.js b/app/blocks/logic/operation.js index 580dbc0..6e8b3fd 100644 --- a/app/blocks/logic/operation.js +++ b/app/blocks/logic/operation.js @@ -55,7 +55,7 @@ export default { fields = { OP: comparator?.toUpperCase() }, - inputs: { + inputs = { A: helpers.expressionToBlock(left, { shadow: 'io_logic_boolean' }), B: helpers.expressionToBlock(right, { shadow: 'io_logic_boolean' }), }