You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the Dimmer or Number is 0, calling sendCommandIfDifferent("0") or calling sendCommandIfDifferent("0.0") should both suppress the command.
Current Behavior
If sending 0 or 0.0 as a command the command is suppressed. If sending the value as a String however, the command is not suppressed.
Possible Solution
My first thought was to make _toOpenhabPrimitiveType smarter but I don't think it has enough information there to do so.
So I think sendCommandIfDifferent needs to see if it can parse the string to a number and if so compare the parsed value to the numericValue.
I'm not sure how to handle Quantity. If I send "0" to a Number:Dimensionless that's 0 % the command isn't suppressed. If I send "0 %" the command is suppressed. Sending 0 the command is also suppressed. So for consistency I'd say we need to parse the value to a Quantity if the Item has a a QuantiyType too but what if the string is without units? Do we assume the same units as the quantityValue? It gets rather complicated, but handlable.
I can supply a PR but need advice on whether to address the Quantity issue as well.
Steps to Reproduce (for Bugs)
Create a test Number and/or Dimmer Item
initialize it with the value 0
from a script call items.TestItem.sendCommandIfDifferent("0") and observe the command was send in any of the usual ways (e.g. events.log)
Context
In my Presence Simulation rule template I was only sending the string version of the value retrieved from persistence as a command to the Item. However, because it's a String, it litters the logs with commands which should not have occurred because the Item is already in that state.
Your Environment
openHAB version used (check Main UI -> About): 4.3 release
openhab-js version used (run console.log('openhab-js ' + utils.OPENHAB_JS_VERSION) from a JS script): 5.8.1
Operating System and version (e.g. desktop or mobile, Windows 10, Raspbian Buster, ...): Official OH Docker Image (debian)
The text was updated successfully, but these errors were encountered:
Expected Behavior
If the Dimmer or Number is
0
, callingsendCommandIfDifferent("0")
or callingsendCommandIfDifferent("0.0")
should both suppress the command.Current Behavior
If sending
0
or0.0
as a command the command is suppressed. If sending the value as a String however, the command is not suppressed.Possible Solution
My first thought was to make
_toOpenhabPrimitiveType
smarter but I don't think it has enough information there to do so.So I think
sendCommandIfDifferent
needs to see if it can parse the string to a number and if so compare the parsed value to the numericValue.I'm not sure how to handle
Quantity
. If I send"0"
to aNumber:Dimensionless
that's0 %
the command isn't suppressed. If I send"0 %"
the command is suppressed. Sending0
the command is also suppressed. So for consistency I'd say we need to parse the value to aQuantity
if the Item has a aQuantiyType
too but what if the string is without units? Do we assume the same units as thequantityValue
? It gets rather complicated, but handlable.I can supply a PR but need advice on whether to address the Quantity issue as well.
Steps to Reproduce (for Bugs)
Number
and/orDimmer
Itemitems.TestItem.sendCommandIfDifferent("0")
and observe the command was send in any of the usual ways (e.g. events.log)Context
In my Presence Simulation rule template I was only sending the string version of the value retrieved from persistence as a command to the Item. However, because it's a String, it litters the logs with commands which should not have occurred because the Item is already in that state.
Your Environment
console.log('openhab-js ' + utils.OPENHAB_JS_VERSION)
from a JS script): 5.8.1The text was updated successfully, but these errors were encountered: