After performing the upgrade (had to install fresh openhabian because of 64bit architecture requirement, imported config backup via openhabian-config), my presence detection rules implemented via Blocky/javascript were all broken since (as I found out when debugging this) now “<“ comparisons on numerical values seem to default to “TRUE” when the numerical value is NULL and the comparison is with a number > 0 (for a simple replication not covering all cases, please see below). First checking whether the value is not equal to NULL fixes this. Seems a weird and possibly unsafe behaviour. Am I missing anything? Have others observed similar issues? Tx!
Update: OK, I can reproduce this with minimal dependencies:
configuration: {}
triggers:
- id: "1"
configuration:
itemName: TestItem
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/javascript
blockSource: '<xml
xmlns="https://developers.google.com/blockly/xml"><variables><variable
type="Number"
id="fd+ewqTn!*-[L/Fz,0bu">myNumber</variable></variables><block
type="math_number" id="s4DKh?qSp1oUzYt=cipK" x="402" y="29"><field
name="NUM">100</field></block><block type="variables_set_dynamic"
id="#s%I.$oGr]6W?6=.Ep+9" x="200" y="69"><field name="VAR"
id="fd+ewqTn!*-[L/Fz,0bu" variabletype="Number">myNumber</field><value
name="VALUE"><block type="logic_null"
id="9q?6j.#~2c9*LFj.}KB7"></block></value><next><block
type="controls_if" id="wquz#w2Viep:Vh(]ROey"><mutation
else="1"></mutation><value name="IF0"><block type="logic_compare"
id="]mR}%T[T/F5toaN)APMj"><field name="OP">LT</field><value
name="A"><block type="variables_get_dynamic"
id="F]%kWbq;zKzeqDG,dXcP"><field name="VAR" id="fd+ewqTn!*-[L/Fz,0bu"
variabletype="Number">myNumber</field></block></value><value
name="B"><block type="math_number" id="A;n$TCGAAthgJr:a=?)!"><field
name="NUM">99</field></block></value></block></value><statement
name="DO0"><block type="oh_log" id="dX|,?}7/A3M$)^eU5V4l"><field
name="severity">warn</field><value name="message"><shadow type="text"
id="IQ$ogy)-,-REdzt}JO8%"><field name="TEXT">abc</field></shadow><block
type="text" id="2389xU6~7my/S3NK/B2O"><field name="TEXT">Test: Comparson
was TRUE</field></block></value></block></statement><statement
name="ELSE"><block type="oh_log" id="W%FNj9wb0(rfvRDM?wtR"><field
name="severity">warn</field><value name="message"><shadow type="text"
id="IQ$ogy)-,-REdzt}JO8%"><field name="TEXT">abc</field></shadow><block
type="text" id="a4-zFG_sS1/yDvLjs?cN"><field name="TEXT">Test: Comparson
was
FALSE</field></block></value></block></statement></block></next></block></xml>'
script: |
var myNumber;
100;
myNumber = null;
if (myNumber < 99) {
console.warn('Test: Comparison was TRUE');
} else {
console.warn('Test: Comparison was FALSE');
}
type: script.ScriptAction
logs “Test: Comparison was TRUE”…
whereas this
configuration: {}
triggers:
- id: "1"
configuration:
itemName: TestItem
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/javascript
blockSource: '<xml
xmlns="https://developers.google.com/blockly/xml"><variables><variable
type="Number"
id="fd+ewqTn!*-[L/Fz,0bu">myNumber</variable></variables><block
type="variables_set_dynamic" id="#s%I.$oGr]6W?6=.Ep+9" x="200"
y="69"><field name="VAR" id="fd+ewqTn!*-[L/Fz,0bu"
variabletype="Number">myNumber</field><value name="VALUE"><block
type="math_number" id="s4DKh?qSp1oUzYt=cipK"><field
name="NUM">100</field></block></value><next><block type="controls_if"
id="wquz#w2Viep:Vh(]ROey"><mutation else="1"></mutation><value
name="IF0"><block type="logic_compare" id="]mR}%T[T/F5toaN)APMj"><field
name="OP">LT</field><value name="A"><block type="variables_get_dynamic"
id="F]%kWbq;zKzeqDG,dXcP"><field name="VAR" id="fd+ewqTn!*-[L/Fz,0bu"
variabletype="Number">myNumber</field></block></value><value
name="B"><block type="math_number" id="A;n$TCGAAthgJr:a=?)!"><field
name="NUM">99</field></block></value></block></value><statement
name="DO0"><block type="oh_log" id="dX|,?}7/A3M$)^eU5V4l"><field
name="severity">warn</field><value name="message"><shadow type="text"
id="IQ$ogy)-,-REdzt}JO8%"><field name="TEXT">abc</field></shadow><block
type="text" id="2389xU6~7my/S3NK/B2O"><field name="TEXT">Test: Comparson
was TRUE</field></block></value></block></statement><statement
name="ELSE"><block type="oh_log" id="W%FNj9wb0(rfvRDM?wtR"><field
name="severity">warn</field><value name="message"><shadow type="text"
id="IQ$ogy)-,-REdzt}JO8%"><field name="TEXT">abc</field></shadow><block
type="text" id="a4-zFG_sS1/yDvLjs?cN"><field name="TEXT">Test: Comparson
was
FALSE</field></block></value></block></statement></block></next></block><block
type="logic_null" id="9q?6j.#~2c9*LFj.}KB7" x="395"
y="98"></block></xml>'
script: |
var myNumber;
myNumber = 100;
if (myNumber < 99) {
console.warn('Test: Comparison was TRUE');
} else {
console.warn('Test: Comparison was FALSE');
}
null;
type: script.ScriptAction
logs “Test: Comparison was FALSE” and this
configuration: {}
triggers:
- id: "1"
configuration:
itemName: TestItem
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/javascript
blockSource: '<xml
xmlns="https://developers.google.com/blockly/xml"><variables><variable
type="Number"
id="fd+ewqTn!*-[L/Fz,0bu">myNumber</variable></variables><block
type="math_number" id="s4DKh?qSp1oUzYt=cipK" x="439" y="31"><field
name="NUM">100</field></block><block type="logic_null"
id="9q?6j.#~2c9*LFj.}KB7" x="629" y="45"></block><block
type="variables_set_dynamic" id="#s%I.$oGr]6W?6=.Ep+9" x="200"
y="69"><field name="VAR" id="fd+ewqTn!*-[L/Fz,0bu"
variabletype="Number">myNumber</field><value name="VALUE"><block
type="logic_null" id=",?[em!D4rHS%wPy]-[0|"></block></value><next><block
type="controls_if" id="wquz#w2Viep:Vh(]ROey"><mutation
else="1"></mutation><value name="IF0"><block type="logic_compare"
id="]mR}%T[T/F5toaN)APMj"><field name="OP">GT</field><value
name="A"><block type="variables_get_dynamic"
id="F]%kWbq;zKzeqDG,dXcP"><field name="VAR" id="fd+ewqTn!*-[L/Fz,0bu"
variabletype="Number">myNumber</field></block></value><value
name="B"><block type="math_number" id="A;n$TCGAAthgJr:a=?)!"><field
name="NUM">99</field></block></value></block></value><statement
name="DO0"><block type="oh_log" id="dX|,?}7/A3M$)^eU5V4l"><field
name="severity">warn</field><value name="message"><shadow type="text"
id="IQ$ogy)-,-REdzt}JO8%"><field name="TEXT">abc</field></shadow><block
type="text" id="2389xU6~7my/S3NK/B2O"><field name="TEXT">Test:
Comparison was
TRUE</field></block></value></block></statement><statement
name="ELSE"><block type="oh_log" id="W%FNj9wb0(rfvRDM?wtR"><field
name="severity">warn</field><value name="message"><shadow type="text"
id="IQ$ogy)-,-REdzt}JO8%"><field name="TEXT">abc</field></shadow><block
type="text" id="a4-zFG_sS1/yDvLjs?cN"><field name="TEXT">Test:
Comparison was
FALSE</field></block></value></block></statement></block></next></block></xml>'
script: |
var myNumber;
100;
null;
myNumber = null;
if (myNumber > 99) {
console.warn('Test: Comparison was TRUE');
} else {
console.warn('Test: Comparison was FALSE');
}
type: script.ScriptAction
logs “Test: Comparison was FALSE”, so possibly NULL is now treated as 0, which seems to have changed from 4.3 to 5, or maybe because of the OS and associated package upgrades?









