Push Notifications with subject and variables?

Hello everybody,

Unfortunately I can not find any documentation about the Notifications in the subject and variables did used.
Is it possible to use subject and variable in the Notifications?

Furthermore, I have to update my Notifications Rules after changes in the Items Files, Rules Files or after a reboot, that they work again.
I use one of the last snapshots with openhabian.
Does anyone know this problem?

Kind regards,

Stefan

Example: (Telegramm)

sendTelegram("BotName", "Some Text: " + Item)

Example (Broadcast Notifikation)

sendBroadcastNotification("Some Text " +item.state + " Another nice text: " + item2.state)

Pushover Example:

pushover("Warning. Item: " + item.label + " (Status " + item.state + ")")

Does this help?

@alkaline yes it work. THX

here is my notification:

sendNotification("myopenHAB Username", "Haustür ist zugesperrt und " + gFenster.members.filter(s | s.state == OPEN).size + " Fenster offen")

Is it also possible to send a subject or mark a part as bold?

Furthermore, I have to update my Notifications Rules after changes in the Items Files, Rules Files or after a reboot, that they work again.

Does anyone know this problem?

Kind regards,
Stefan

1 Like

You need to provide more information.

Post your rule.

What do you change to make it work again?

Post any related Items.

Here is a part of my config:

relevant ITEMS

//--> Nuki Bridge
Number  nukiHaustuer_action   		"Aktion"      					<nuki>  				{http=">[1:GET:http://IP-Adress:8080/lockaction?token=TOKEN&nukiId=ID&action=1] >[2:GET:http://IP-Adress:8080/lockaction?token=TOKEN&nukiId=ID&&action=2] >[3:GET:http://IP-Adress:8080/lockaction?token=TOKEN&nukiId=ID&&action=3]"}
Number  nukiHaustuer_status  		"Status Haustür [%s]" 			<haustuer>				{http="<[http://IP-Adress:8080/lockState?token=TOKEN&nukiId=ID&:30000:JSONPATH($.state)]"}
String  nukiHaustuer_LowBattery 	"Haustür Low Battery [%s]" 		<battery-off>			{http="<[http://IP-Adress:8080/lockState?token=TOKEN&nukiId=ID&:300000:JSONPATH($.batteryCritical)]"}

//--> Fenster Alarm
Switch FensterOffen					"ein Fenster offen"							<contact>
String FensterAlert 				"Warnung [%s]" 								<contact>
Switch FensterAlertActiveHaustuer	"Haustür zugesperrt Fenster offen"			<error>
Switch FensterAlertActiveRegen		"Regenwarnung Fenster offen"				<error>

relevant RULES:

rule "nukiHaustuer_status,1,2,3" 
when
	Item nukiHaustuer_action received command
then
	if (nukiHaustuer_action.state == 1){
		sendCommand (nukiHaustuer_status,2)
		Thread::sleep(8000)
		sendCommand (nukiHaustuer_status,3)
		Thread::sleep(10000)
		sendCommand (nukiHaustuer_action,0)
	}
	if (nukiHaustuer_action.state == 2){
		sendCommand (nukiHaustuer_status,4)
		Thread::sleep(5000)
		sendCommand (nukiHaustuer_status,1)
		Thread::sleep(10000)
		sendCommand (nukiHaustuer_action,0)
	}
	if (nukiHaustuer_action.state == 3){
		sendCommand (nukiHaustuer_status,5)
		Thread::sleep(8000)
		sendCommand (nukiHaustuer_status,3)
		Thread::sleep(6000)
		sendCommand (nukiHaustuer_action,0)
	}
end

rule "FensterOffen,ON,OFF" 
when
	Item gFenster received update
then
	if (gFenster.state == OPEN){
		sendCommand (FensterOffen, ON)
		sendCommand(FensterAlert,"Fenster offen")
	}
	if(gFenster.state == CLOSED){
		sendCommand(FensterOffen, OFF)
		sendCommand(FensterAlert,"Fenster geschlossen")
		sendCommand(FensterAlertActiveHaustuer, OFF)
		sendCommand(FensterAlertActiveRegen, OFF)
	}
end

rule "FensterAlertActiveHaustuer, ON" 
when
	Item nukiHaustuer_status received update or
	Item FensterOffen received update
then
	if (FensterOffen.state == ON && nukiHaustuer_status.state == 1 ) {
		sendCommand (FensterAlertActiveHaustuer, ON)
	}
	if (nukiHaustuer_status.state == 3 ) {
		sendCommand (FensterAlertActiveHaustuer, OFF)		
	}
end

rule "FensterAlertActiveRegen,ON,OFF" 
when
	Item FensterOffen received update or
	Item RainH received update
then
	if (gFensterRegen.state == OPEN && RainH.state > 0)	{
		sendCommand (FensterAlertActiveRegen, ON)
	}
	if (RainH.state == 0 || gFensterRegen.state == CLOSED )	{
		sendCommand (FensterAlertActiveRegen, OFF)
	}	
end

rule "FensterAlertActiveHaustuer, ON" 
when
	Item FensterAlertActiveHaustuer changed from OFF to ON
then
	sendNotification("myOpenHAB User", "Haustür ist zugesperrt und " + gFenster.members.filter(s | s.state == OPEN).size + " Fenster offen")
end
 
rule "FensterAlertActiveRegen, ON" 
when
	Item FensterAlertActiveRegen changed from OFF to ON
then
	sendNotification("myOpenHAB User", "Regenwarnung und " + gFensterRegen.members.filter(s | s.state == OPEN).size + " Fenster offen")
end

For working, I only “change” (it´s more update no changes) the RULES files after any changes in ITEMS files or Sitemap files.

any ideas?

Well yes, if you change the name of an item or add new items of course you need to change the rules to use the new names. They do not automatically synchronize with each other.

Or do you mean that when you make a change to an items file you must touch the rules file it wise everything stops working.

If so, I’m what easy for it stop working?
What errors do you see in the logs?
How do you know the rule stops working?

@rlkoshak

Yes I meant any change in any ITEMS files or in the Sitemap.
I was already aware of the fact that changes to items that directly affecting RULES, the RULES would no longer work for them.

I notice this to the relevant rules, which I posted, that if the front door (Haustür) is locked and a window (Fenster) is open, no notifications come.

To fix this, I update the affected RULES without any changes by Designer or Notepad++.

Are you using persistence? When you change a .items file all your Items get reset to uninitialized (i.e. NULL). If you use persistence with restoreOnStartup then your Items will be initialized to their most recently saved value.

The problem is probably because your alert rules only trigger when the Item changes from OFF to ON but when you change a .items file without restoreOnStartup the next time FensterAlertActiveHaustuer changes it will be changing from NULL to ON so the rule doesn’t trigger.

See

Thanks for the hint.
No, I do not use persistence.

But I’ve found my thought mistake.

The hint with “uninitialized (i.e. NULL)” opened my eyes.
I changed the RULES, so I did not need three ITEMS status changes until all the ITEMS have the appropriate status. By all the nesting rules, it would have required three different changes until the notification is activated.

The rules also work after changes in the ITEM files. However, the status of some ITEMS is correctly first uninitialized (i.e., NULL).

Thanks you so much for open my eyes