Hi,
I used a script base rule that checked if my washing machine has finished it´s job. OH3 imported it successfully and splitted it into 3 parts (don´t know why, but it worked.)
Unfortunately the rule does not work since I updated the system the ver 3.4.0. I don´t know why, it just seems to not trigger.
So I tried to recreate the rule in the Rule editor like this:
Name: Wasching machine ready message
When Item washingmachine is updated
execute given script. The script:
val Number MODE_OFF = 0
val Number MODE_STANDBY = 1
val Number MODE_ACTIVE = 2
val Number MODE_FINISHED = 3
var Boolean cycle = 0
rule "Waschmaschine fertig"
when
Item Waschmaschine_WaschmaschineVerbrauchAktuell changed
then
if (Waschmaschine_WaschmaschineVerbrauchAktuell.state > 100 )
{
Waschmaschine_OpState.postUpdate(MODE_ACTIVE)
cycle=0
}
else if (Waschmaschine_WaschmaschineVerbrauchAktuell.state <= 5 && Waschmaschine_OpState.state == MODE_ACTIVE)
{
Waschmaschine_OpState.postUpdate(MODE_FINISHED)
}
end
Next corresponding rule:
Name: Washingmachine send notification
When Item OpState has changed
execute given script. The script:
val Number MODE_OFF = 0
val Number MODE_STANDBY = 1
val Number MODE_ACTIVE = 2
val Number MODE_FINISHED = 3
rule "Waschmaschine Nachrichten"
when
Item Waschmaschine_OpState changed
then
if (Waschmaschine_OpState.state == MODE_FINISHED) {
sendNotification("XXX@web.de", "Waschmaschine fertig!") //Nachricht wird hiermit abgesendet
EchoWzTextToSpeech_Sprich.sendCommand('Waschmaschine fertig')
}
end
Any idea why it´s not working anymore?
edit: I found out the the item Waschmaschine_OpState hasn´t changed for a few weeks now. Did sth. change in the “postUpdate” method?
BTW This is what I´ve created using ChatGPT, should it run?
rule "Waschmaschine Verbrauch Überwachung"
when
Item Waschmaschine_WaschmaschineVerbrauchAktuell changed
then
if (Waschmaschine_WaschmaschineVerbrauchAktuell.state > 100) {
Waschmaschine_OpState.postUpdate(1)
} else if (Waschmaschine_WaschmaschineVerbrauchAktuell.state < 6 && Waschmaschine_OpState.state == 1) {
Waschmaschine_OpState.postUpdate(2)
} else if (Waschmaschine_WaschmaschineVerbrauchAktuell.state < 6 && Waschmaschine_OpState.state == 2) {
Waschmaschine_OpState.postUpdate(0)
sendNotification("XXX@web.de", "Waschmaschine fertig!")
}
end
edit2: To make it easier I created a new rule in the OH3 UI but this time as a script. There I used the ChatGPT code above.
After injecting some states (using nodeRed) I can verify from logviewer that the states change, but no rule is ever triggered. What´s going on here??
edit3: Just had a look in my openhab.log, wow, what srcewed my rules liket this??:
2023-02-06 15:00:55.483 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'waschgeraete-1' failed: The name 'sendNotification' cannot be resolved to an item or type; line 14, column 9, length 59 in waschgeraete
2023-02-06 15:00:57.059 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '34a4c0adb7' failed: var Integer Notification1_Sent = 0
var Integer Notification2_Sent = 0
val Number MODE_OFF = 0
val Number MODE_STANDBY = 1
val Number MODE_ACTIVE = 2
val Number MODE_FINISHED = 3
rule "Waschmaschine Nachrichten"
when
Item Waschmaschine_OpState changed
then
if (Waschmaschine_OpState.state == MODE_FINISHED) {
sendNotification("XXX@web.de", "Waschmaschine fertig!") //Nachricht wird hiermit abgesendet
EchoWzTextToSpeech_Sprich.sendCommand('Waschmaschine fertig')
}
end
1. The method or field rule is undefined; line 9, column 180, length 4
2. The method or field when is undefined; line 10, column 213, length 4
3. The method or field changed is undefined; line 11, column 249, length 7
4. The method or field then is undefined; line 12, column 257, length 4
5. The method or field end is undefined; line 17, column 492, length 3
6. This expression is not allowed in this context, since it doesn't cause any side effects.; line 9, column 185, length 27
7. This expression is not allowed in this context, since it doesn't cause any side effects.; line 11, column 222, length 4
8. This expression is not allowed in this context, since it doesn't cause any side effects.; line 11, column 227, length 21