[SOLVED] Creating a rule with push notification for my iphone

hello,

again i got a question and need a little bit of your help.

i am trying to create a rule, that sends time-based a push notification (states of a few items) to my iphone. the openhab-app is installed on the iphone and the openhab cloudservice is activated.

what are the next steps now? do i just need to create a rule now (which commands?) oder do i have to install/configure some more addons (which do i need?)

thanks for your help!

alex

Look at this: http://www.myopenhab.org

Under “Push Notifications” it tells how to use in rules.

Or you can use pushover or pushsafer bindings.

now i got another two questiona to this topic:

now i got this rule and so far it is working fine, but i want the notification to be sent when the value rises above 50. how can i express it in the rule?

rule "Luftfeuchtigkeit"
when
	Item tado_wohnzimmer_Humidity changed or
	Item tado_badezimmer_Humidity changed or
	Item tado_schlafzimmer_Humidity changed
then
	sendNotification("xxx@yyy.de",
	"Die Luftfeuchtigkeit ist zu hoch - Fenster öffnen und Lüften!"
	)
end

also it would be great to know, how i can get the message in two lines…

thanks for your help!

For a new line you may want to try \n

thanks, it tried it out, but it didnt work - or do i have to keep it out of the “”?

	"Die Luftfeuchtigkeit ist zu hoch! /n Fenster öffnen und Lüften!"

You’d probably use if

if (somevalue > 50) {
   // do something
}

Remember you would want to use the .state of an Item to compare its value

Too bad. I think you have to keep it in the quotes, but maybe ‘notification’ just ignores it. wont hurt to try outside the quotes I gess

i am not sure but i think then i would get a notification for every change thats above 50, but i want to get just one notification, when the value of one of the items rises above 50. the next notification should be sent when the value falls under 50 and then rises again…

i thought there maybe could be a way to create the rule like this:
send notificatition, when the value changes from <50 to >50

So long as your rules is triggered on change, you can construct a rule using the implicit variable previousState
http://docs.openhab.org/configuration/rules-dsl.html#implicit-variables-inside-the-execution-block

if (somevalue > 49 && previousState <  50) {
   // do something
}

thank you very much. again i learned a lot and the notifications work great now!

so there is just the point about formatting the notification. is there a way to format the notification in different lines?

anyone an idea of formatting the notification to get the result in different lines`?

You might want to try \n as stated and not /n as you have in your code…
I‘ve not tried it but a newline is definitely indicated by a backslash + n…
Maybe this helps.
By the way: can you provide a screenshot of the actual notification?
I am searching for something good-looking and ad-free and configurable (maybe with icon for warnings) for iOS…

Hello Werner,

sorry for my late reply, but i had to do a completely new installation of my homeserver and also my openhab, what took a while.

It seems like in this time some changes were made, because now i get the output i was especting. Nevertheless you where right with your hint to use \n - but now you get a full empty line using \n.

actually my code looks like this an i get the following ios notification:

rule "Spritpreise"
when
	Item Test_Notification changed or
	Item TankstelleHoyerDodenhof_E10 changed or
	Item TankstelleTeamLilienthal_E10 changed or
	Item TankstelleHoyerOttersberg_E10 changed
then
	if (Rule_Spritpreise.state == ON) {
	sendNotification("abc@exy.com",
	"Aktuelle E10-Preise:
	Hoyer Dodenhof " +TankstelleHoyerDodenhof_E10.state+ "€
	Hoyer Ottersberg " +TankstelleHoyerOttersberg_E10.state+ "€
	TEAM Lilienthal " +TankstelleTeamLilienthal_E10.state+ "€"
	)
	}

1 Like

Brilliant thanks! If anyone is still struggling I also had to remove a previous device from myopenhab, reinstall the app on my iphone and then it worked as per instructions above.