I would like to have a rule on OH3.2 (textfiles) which catches all messages coming from different rules and sends the messages via Pushover.
rule "Message when Button pushed"
when
Item Button changed
then
Pushover_message.postUpdate(Button changed;soundBike)
end
But I don’t know how to deal with “Button changed” (MESSAGE) and “soundBike” (SOUND).
rule "Pushover master"
when
Item Pushover_message received update
then
logInfo("PUSHOVER","Message has been caught and sent")
val actions = getActions("pushover", "pushover:pushover-account:SOUND")
actions.sendHtmlMessage("MESSAGE", "openHAB3")
}
end
In the UI this would be simple. In text files, first of all Pushover_message must be a String Item. As such, the update you post to it must be a String. What you are updating it to now is syntactic nonsense. Put it in quotes.
Then in your received update rule you’ll need to parse the String "Button changed;soundbike" and pass them to the action as the action requires.
If you don’t need a return value, you might put the Pushover_Message code into a Rules DSL Script and call it using the callScript() action. Actions | openHAB.
In the UI, the easiest would be to create a Script with the Pushover_message and call that from your rules that want to send the message. You can pass values to the called rule or use the sharedCache.
rule "Pushover Master"
when
Item PushoverMessage received update
then
logInfo("PUSHOVERMASTER","Rule getriggert")
if (PushoverMessage.state == 1) {
logInfo("PUSHOVERMASTER","Washer is FINISHED as it was ACTIVE before - POMASTER")
val actions = getActions("pushover", "pushover:pushover-account:soundBike")
actions.sendHtmlMessage("Washer is FINISHED as it was ACTIVE before - POMASTER", "openHAB3")
}
if (PushoverMessage.state == 2) {
logInfo("PUSHOVERMASTER","Dishwasher is FINISHED as it was ACTIVE before - POMASTER")
val actions = getActions("pushover", "pushover:pushover-account:soundBike")
actions.sendHtmlMessage("Dishwasher is FINISHED as it was ACTIVE before - POMASTER", "openHAB3")
}
else {
return
}
end
It works except that the pushover message is not sent
I got this errors:
[INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PushoverMessage' changed from 2 to 1
[INFO ] [hab.core.model.script.PUSHOVERMASTER] - Rule getriggert
[INFO ] [hab.core.model.script.PUSHOVERMASTER] - Washer is FINISHED as it was ACTIVE before - POMASTER
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'pushovermaster-1' failed: null in pushovermaster