There might be a bug with hysteresis settings overall. I tested another rule that should fire an alert when it starts to rain, i.e. when the rain amount in the past hour exceeds 0.3mm/h.
-
The item that holds the rain in mm/h is a dimensionless number item with a custom state description %.1f mm/h
-
The rule uses 0.3 as the initial threshold and 0.3 as the hysteresis, so alerting stops after reaching 0.0 again
var group = 'gRainWarnings';
var thresholdStr = '0.3';
var operator = '>=';
var alertRuleUID = '9586d73c23';
var hystRange = '0.3';
var initAlertRuleUID = '9586d73c23';
- I am using the initAlertRule because at first, I noticed multiple events with alerting whenever the item received an update. Thus the rule now looks as the following:
if(isInitialAlert) {
console.log('It started to rain');
actions.NotificationAction.sendBroadcastNotification('It started to rain');
}
I would expect a single notification, the first time the threshold is above 0.3. What I currently get is a notification everytime the item is updating and above 0.3.
I ran the script config without the event and it does not show any errors in the log:
2024-06-10 11:36:44.428 [INFO ] [les_tools.Threshold Alert.3ac6b6a352] - Rule triggered without an Item event, ExecutionEvent checking the rule config
2024-06-10 11:36:44.433 [INFO ] [les_tools.Threshold Alert.3ac6b6a352] - Cancelling any running timers
2024-06-10 11:36:44.434 [DEBUG] [org.eclipse.jetty.io.ChannelEndPoint] - flushed 7 SocketChannelEndPoint@140f6ab{l=/192.168.0.15:8080,r=/192.168.0.23:59196,OPEN,fill=-,flush=W,to=10/30000}{io=0/0,kio=0,kro=1}->HttpConnection@d18037[p=HttpParser{s=CONTENT,0 of -1},g=HttpGenerator@13eaf63{s=COMMITTED}]=>HttpChannelOverHttp@106026e{s=HttpChannelState@73aa79{s=WAITING rs=ASYNC os=COMMITTED is=IDLE awp=false se=false i=false al=2},r=3,c=false/false,a=WAITING,uri=//192.168.0.15:8080/rest/events?topics=openhab/rules/3ac6b6a352/*,age=51895}
2024-06-10 11:36:44.438 [INFO ] [les_tools.Threshold Alert.3ac6b6a352] - Items without thresholdAlert alertDelay metadata will alert immediately
2024-06-10 11:36:44.440 [INFO ] [les_tools.Threshold Alert.3ac6b6a352] - Items without thresholdAlert remPeriod metadata will not repeat alerts
2024-06-10 11:36:44.496 [INFO ] [les_tools.Threshold Alert.3ac6b6a352] - No end alert rule configured, no rule will be called when alerting ends
2024-06-10 11:36:44.559 [INFO ] [les_tools.Threshold Alert.3ac6b6a352] - These Items do not have thresholdAlert metadata and will use the default properties defined in the rule: Netatmo_Rain_Sensor__Rain_1h
2024-06-10 11:36:44.621 [INFO ] [les_tools.Threshold Alert.3ac6b6a352] - Threshold Alert configs check out as OK
It started to rain a few minutes ago. This is what I see in the logs:
2024-06-10 15:06:33.128 [INFO ] [nhab.automation.script.ui.9586d73c23] - Rain threshold triggered with Item Netatmo_Rain_Sensor__Rain_1h, state 0.32123123 initialAlert true and alerting false
2024-06-10 15:06:33.341 [INFO ] [nhab.automation.script.ui.9586d73c23] - It started to rain
2024-06-10 15:06:33.992 [INFO ] [nhab.automation.script.ui.9586d73c23] - Rain threshold triggered with Item Netatmo_Rain_Sensor__Rain_1h, state 0.32123123 initialAlert false and alerting true
2024-06-10 15:16:33.828 [INFO ] [nhab.automation.script.ui.9586d73c23] - Rain threshold triggered with Item Netatmo_Rain_Sensor__Rain_1h, state 1.399999976158142 initialAlert true and alerting false
2024-06-10 15:16:33.831 [INFO ] [nhab.automation.script.ui.9586d73c23] - It started to rain
2024-06-10 15:16:33.982 [INFO ] [nhab.automation.script.ui.9586d73c23] - Rain threshold triggered with Item Netatmo_Rain_Sensor__Rain_1h, state 1.399999976158142 initialAlert false and alerting true
Any ideas?