rkoshak / openhab-rules-tools

Library functions, classes, and examples to reuse in the development of new Rules.
Other
62 stars 23 forks source link

ThresholdAlert Bug Fixes #106

Closed rkoshak closed 1 year ago

rkoshak commented 1 year ago

Bug Fixes:

Function Problem Fix
stateToValue The JS function isNaN returns true for empty string causing problems when hysteresis was not set. Added if clause to handle empty string explicetly.
isAlertingState The ternary operation in the log statement was not working, showing the wrong value in the logs. Calculate the return value and save to a variable instead of recalculating it in the log statement.
notAlerting Testing the wrong timer in record before cancelling initAlertTimer Fixed if statement
refreshRecord It's not clear which value is being sent to stateToValue for conversion. Added log statements before calls to stateToValue indicating what is being converted (state, threshold, hyst).
procEvent state is already converted to a value before this function is called Use state instead of converting it again.
procEvent record[name] should only be initialized once Don't reinitialize if one of the timers or alerted do not exist. Treat those cases as an error.
procEvent Code simplicity Let notAlerting handle the case where we are no longer alerting but there is no endAlert rule to call.
refreshRecord Missing newline after Init Alert Rule ID in log statement.
Body Missing case for ItemStateUpdatedEvent Added case for ItemStateUpdateEvent to handle cases where the default trigger is changed to received update from changed.
Body It's not always clear when the rule is triggered manually Change debug log statement to info level when manually triggered.