Push Notification an Android

Hallo!

Für das iPhone gibt es ja die Möglichkeit mit Prowl Push Notification zu senden!

http://www.ip-symcon.de/forum/threads/9322-iPhone-Push-Notification-von-IP-Symcon?highlight=PROWL

Gibt es sowas für Andriod auch?

Danke

Angeschaut und experimentiert habe ich mit NotifyMyAndroid, Pushover, GooglePush und Twitter.

Schlussendlich bin ich bei Pushover gelandet und inzwischen seit einigen Monaten geblieben.
Kriterien waren für mich eine einfache API (ist in der FAQ verlinkt), Zuverlässigkeit (Verfügbarkeit und Zustelldauer) und eine individuelle Adressierung von registrierten Telefonen.

Wenn du Tasker nutzt, kann ich dir Autoremote (Plugin für Tasker) empfehlen. Ich bekomme so meine Meldungen seit ca. einem halben Jahr aufs Handy.

Hallo Blopp!

Kannst du bitte eine klein Anleitung rein stelle u. ein Beispielscript?

Wäre toll von dir!!

Danke

Hier der Ansatz für Pushover:

  1. php-Api aus dem Link der Pushover-FAQ nach IP-Symcon kopieren (Suche in in FAQ nach „php-pushover“)

  2. Das unten stehende Sende-Script zum Aufruf der API erstellen.
    Das Script wird bei mir durch die Aktualisierung einer String-Variable „Nachricht“ getriggert, in welche die zu schickende Nachricht geschrieben wird.


require 'Pushover_API.ips.php';

$message = GetValue(12345 /*[WWW\Messanger\Pushover\History\Nachricht]*/);

if ($message <> '')
{
        $push->setToken('app token goes here');
        $push->setUser('user token goes here');
	$push = new Pushover();
	$push->setMessage($message);
	$go = $push->send();

}

Hallo Leute,

irgendwie will das bei mir nicht funktionieren mit dem Pushover.

Ich bin wie folgt vorgegangen…

ich hab als erstes ein Skript erstellt in das ich den Code der API reinkopiert hab.

dann hab ich ein weiter skript mit dem foldenden Code erstellt


<?

require '55206.ips.php' ;

$message = GetValue(56547 /*[Aussenbereich\Aussentemp\Temperatur]*/);

if ($message <> '')
{
        $push->setToken('aFLiPMzFWTG7sKQB2vVDVdgBxtHGEq');
        $push->setUser('u8VTEBfRvq7ZfyqaJuHaATXY9wTp2F');
    $push = new Pushover();
    $push->setMessage($message);
    $go = $push->send();
}

?>

wenn ich das skript ausführe bekomme ich folgenden Fehler:

Notice: Undefined variable: push in C:\IP-Symcon\scripts\24660.ips.php on line 9

Fatal error: Call to a member function setToken() on a non-object in C:\IP-Symcon\scripts\24660.ips.php on line 9
Abort Processing during Fatal-Error: Call to a member function setToken() on a non-object
Error in Script C:\IP-Symcon\scripts\24660.ips.php on Line 9

Leider komm ich nicht auf des Rätsels Lösung!!

Hat hier vielleicht jemand von euch eine Idee???

Vielen Dank schon mal im Voraus!!!

versuch mal die folgende Zeile vor SetToken einzufügen:


$push = new Pushover(); 

Das hat leider nicht funktioniert.

Ich hab das Skript wie folgt geändert:

<?

require '55206.ips.php' ;

$message = GetValue(56547 /*[Aussenbereich\Aussentemp\Temperatur]*/);

if ($message <> '')
{
         $push = new Pushover();
		  $push->setToken('aFLiPMzFWTG7sKQB2vVDVdgBxtHGEq');
        $push->setUser('u8VTEBfRvq7ZfyqaJuHaATXY9wTp2F');
    $push->setPriority('2');
	 $push->setExpire('2');
    $push->setMessage($message);
    $go = $push->send();
}

?>

Da bekomme ich die Fehlermeldung

Fatal error: Call to undefined method Pushover::getExpire() in [Scripte\Pushover_API] on line 427
Abort Processing during Fatal-Error: Call to undefined method Pushover::getExpire()
Error in Script C:\IP-Symcon\scripts\55206.ips.php on Line 427

Das Skript auf das sich der Fehler bezieht sie so aus:

<?
/**
* php-pushover
*
* PHP service wrapper for the pushover.net API: https://pushover.net/api
*
* @author Chris Schalenborgh <chris.s@kryap.com>
* @version 0.2
* @package php-pushover
* @example test.php
* @link https://pushover.net/api
* @license BSD License
*/

class Pushover
{
// api url
const API_URL = 'https://api.pushover.net/1/messages.xml';

/**
* Application API token
*
* @var string
*/
private $_token;

/**
* User API token
*
* @var string
*/
private $_user;

/**
* Turn on/off debug mode
*
* @var bool
*/
private $_debug = false;

/**
* Title of the message
*
* @var string
*/
private $_title;

/**
* The message itself (up to 512 characters)
*
* @var string
*/
private $_message;

/**
* Timestamp in Unix timestamp format
*
* @var int
*/
private $_timestamp;

/**
* User's device (user specific)
*
* @var string
*/
private $_device;

/**
* Priority of the message. Can be 0, 1 or 2. High-priority messages (1) override a user's "quiet hours" setting and will always be delivered any time they are received. High priority messages are highlighted in red in the Android and iOS clients. Emergency Priority (2) messages work similar to High-Priority messages, but they are repeated until the message is acknowledged by the user.
*
* @var string
*/
private $_priority = 0;

/**
* Include a Supplementary URL (up to 200 characters)
*
* @var string
*/
private $_url;

/**
* Title of the included URL (up to 50 characters)
*
* @var string
*/
private $_url_title;

/**
* The Retry parameter is only used when the Priority is set to 2 (or emergency-priority), and specifies how often (in seconds) the Pushover servers will send the same notification to the user. In a situation where your user might be in a noisy environment or sleeping, retrying the notification (with sound and vibration) will help get his or her attention. This parameter must have a value of at least 30 seconds between retries.
*
* @var int
*/
private $_retry;

/**
* The expire parameter is only used when the Priority is set to 2 (or emergency-priority), and specifies how many seconds your notification will continue to be retried for. If the notification has not been acknowledged in expire seconds, it will be marked as expired and will stop being sent to the user. This parameter must have a maximum value of at most 86400 seconds (24 hours).
*
* @var int
*/
private $_expire;

/**
* The optional callback parameter may be supplied with a publicly-accessible URL that our servers will send a request to when the user has acknowledged your notification.
*
* @var string
*/
private $_callback;

/**
* The sound parameter. Get an up-to-date sound list from https://api.pushover.net/1/sounds.json?token=
*
* @var int
*/
private $_sound;

/**
* Default constructor
*/
public function __construct () {
    }

/**
* Set API token
*
* @param string $token Your app API key.
*
* @return void
*/
    public function setToken ($token) {
        $this->_token = (string)$token;
    }

/**
* Get API token
*
* @return string
*/
    public function getToken () {
        return $this->_token;
    }

/**
* Set API user
*
* @param string $user The user's API key.
*
* @return void
*/
    public function setUser ($user) {
        $this->_user = (string)$user;
    }

/**
* Get API user
*
* @return string
*/
    public function getUser () {
        return $this->_user;
    }

/**
* Set message title
*
* @param string $title Title of push notification.
*
* @return void
*/
    public function setTitle ($title) {
        $this->_title = (string)$title;
    }

/**
* Get message title
*
* @return string
*/
    public function getTitle () {
        return $this->_title;
    }

/**
* Set Retry Time
*
* @param int $retry The retry time (in seconds). Must have a value of at least 30 seconds.
*/
public function setRetry ($retry) {
$this->_retry = (int)$retry;
}

/**
* Get Retry Time
*
* @return int
*/
public function getRetry() {
return $this->_retry;
}

/**
* Set Expire Time
*
* @param int $expire The expiry time (in seconds). Must have a maximum value of at most, 86400 seconds.
*/
public function setExpire ($expire) {
$this->_expire = (int)$expire;
}

/**
* Set Callback URL
*
* @param string $callback a publically-accessible URL that Pushover sends a request to when the user has acknowledged your notification.
*/
public function setCallback ($callback) {
$this->_callback = $callback;
}

/**
* Get Callback URL
*
* @return int
*/
public function getCallback() {
return $this->_callback;
}

/**
* Set message
*
* @param string $msg Message of push notification.
*
* @return void
*/
    public function setMessage ($msg) {
        $this->_message = (string)$msg;
    }

/**
* Get message
*
* @return string
*/
    public function getMessage () {
        return $this->_message;
    }

/**
* Set device
*
* @param string $device Leave this empty if you want to send to all user's devices. This can be user specific!
*
* @return void
*/
    public function setDevice ($device) {
        $this->_device = (string)$device;
    }

/**
* Get device
*
* @return string
*/
    public function getDevice () {
        return $this->_device;
    }

/**
* Set timestamp
*
* Messages are stored on the Pushover servers with a timestamp of when they were initially received through the API. This timestamp is sent to and shown on client devices, and messages are listed in order of these timestamps. In most cases, this default timestamp is acceptable. This is not for scheduling!
*
* @param int $time dispaly time on device
*
* @return void
*/
    public function setTimestamp ($time) {
        $this->_timestamp = (int)$time;
    }

/**
* Get timestamp
*
* @return int
*/
    public function getTimestamp () {
        return $this->_timestamp;
    }

/**
* Set priority (-1, 0 or 1)
*
* -1 Low priority notifications.
* 0 Default.
* 1 triggers a high-priority alert that always generates sound and vibration.
* 2 triggers the same high-priority alert that #1 does; but is repeated until the notification is acknowledged by the user.
*
* @param int $priority priority level.
*
* @return void
*/
    public function setPriority ($priority) {
        $this->_priority = (int)$priority;
    }

/**
* Get priority
*
* @return int
*/
    public function getPriority () {
        return $this->_priority;
    }

/**
* Set url
*
* @param string $url Add an url to your notification.
*
* @return void
*/
    public function setUrl ($url) {
        $this->_url = (string)$url;
    }

/**
* Get url
*
* @return string
*/
    public function getUrl () {
        return $this->_url;
    }

/**
* Set url title
*
* @param string $url_title A title if you want to show a text instead of the actual url.
*
* @return void
*/
    public function setUrlTitle ($url_title) {
        $this->_url_title = (string)$url_title;
    }

/**
* Get url title
*
* @return string
*/
    public function getUrlTitle () {
        return $this->_url_title;
    }




/**
* Set debug mode
*
* @param bool $debug Enable this to receive detailed input and output info.
*
* @return void
*/
    public function setDebug ($debug) {
        $this->_debug = (boolean)$debug;
    }

/**
* Get debug mode
*
* @return bool
*/
    public function getDebug () {
        return $this->_debug;
    }



/**
* Set sound
*
* @param string $sound If no sound parameter is specified, the user's default tone will play. If the user has not chosen a custom sound, the standard Pushover sound will play.
*
* @return void
*/
    public function setSound ($sound) {
        $this->_sound = (string)$sound;
    }

/**
* Get sound
*
* @return string
*/
    public function getSound () {
        return $this->_sound;
    }

/**
* Send message to Pushover API
*
* @return bool
*/
public function send() {
if(!Empty($this->_token) && !Empty($this->_user) && !Empty($this->_message)) {
if(!isset($this->_timestamp)) $this->setTimestamp(time());

$c = curl_init();
curl_setopt($c, CURLOPT_URL, self::API_URL);
curl_setopt($c, CURLOPT_HEADER, false);
/*
if possible, set CURLOPT_SSL_VERIFYPEER to true..
- http://www.tehuber.com/phps/cabundlegen.phps
*/
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_POSTFIELDS, array(
'token' => $this->getToken(),
'user' => $this->getUser(),
'title' => $this->getTitle(),
'message' => $this->getMessage(),
'device' => $this->getDevice(),
'priority' => $this->getPriority(),
'timestamp' => $this->getTimestamp(),
'expire' => $this->getExpire(),
'retry' => $this->getRetry(),
'callback' => $this->getCallback(),
'url' => $this->getUrl(),
'sound' => $this->getSound(),
'url_title' => $this->getUrlTitle()
));
$response = curl_exec($c);
$xml = simplexml_load_string($response);

if($this->getDebug()) {
return array('output' => $xml, 'input' => $this);
}
else {
return ($xml->status == 1) ? true : false;
}
}
}
}
?>

Danke nochmal für eure Hilfe!!

Hi,

ich spiele auch gerade mit Pushover. Ich nutze aber nicht die Klasse sondern das curl Beispiel aus der FAQ.
Es muss allerdings der Parameter CURLOPT_SSL_VERIFYPEER=false hinzugefügt werden, damit es funktioniert.

Mit diesem Beispiel klappt es bei mir (token und user entsprechend anpassen):


<?
curl_setopt_array($ch = curl_init(), array(
	CURLOPT_URL => "https://api.pushover.net/1/messages.json",
	CURLOPT_SSL_VERIFYPEER => false,
	CURLOPT_POSTFIELDS => array(
	"token" => "bFgs.............",
	"user" => "nhZghJI...............",
	"message" => "Der Hamster hat hunger!",
	"sound" => "siren",
	"priority" => "2",
	"retry" => "30",
	"expire" => "3600",
)));
curl_exec($ch);
curl_close($ch);

?>

@mirank

In Deiner kopierten Api gibt es keine definierte Funktion „getExpire“.
Auf der Download-Seite ist diese hinterlegt.

kopiere Dir die Api am besten nochmal vollständig.

@mirank

Ich habe die Zeile 427 auskommentiert //, mit

$push->setPriority('1');$push->setExpire('1'); 

funktioniert es:o

@blopp
Wo steht was „getExpire“, ich finde nichts:confused:
In der API habe ich auch nichts gefunden.

ab Zeile 220:


+	/**
+	 * Get Callback URL
+	 *
 	 * @return int
	 */
-	public function getExpire() {
-		return $this->_expire; 
+	public function getCallback() {
+		return $this->_callback;
 	}
-	

public function getExpire() {return $this->_expire};

Klammer fehlt:)

Vielen Dank euch allen!!

Mit hilfe eurer Tips hab ichs zum laufen bekommen!!

Besten Dank

Hallo,

hab Pushover auch ein wenig getestet. Funktioniert soweit ganz gut… Aber ist es richtig, dass es kein Popup auf dem Display gibt? Ähnlich wie WhatsApp oder Kalendererinnerungen?

PopUp kenne ich auch nicht.
Bei eingehender Nachricht, kann ich zumindest die erste Zeile in der Menüleiste lesen. Das reicht mir.

Mehr als die erste Zeile in der Statusleiste hab ich auch nicht.

Leider werden Umlaute nicht korrekt dargestellt. Nach längerer Suche stellte sich heraus, daß Symcon die PHP-Scripte falsch abspeichert. Der eingebaute Webserver ist UTF-8 codiert, jedoch werden die scripte in Windows-Ansi 1252 abgespeichert.
Also im Verzeichnis Ip-Symcon\Scripts das entsprechende Script mit einem geeigneten Editor (Ultraedit z.B.) öffnen und die Datei im UTF-8 Format abspeichern. Nun werden auch Umlaute korrekt dargestellt.

Hallo,

hab die Pushover Anbindung mal in ein kleines Modul gepackt. So lassen sich Messages ohne kompliziertes Skripting in der IPS Console erstellen.

Das ganze ist noch sehr unsauber programmiert, Basis ist ein CURL Aufruf.

-> git://github.com/ccie32305/SymconPushover.git

Gerne Feedback oder Verbesserungsvorschläge

Danke für das Plugin. Hab allerdings ein kleines Problem:
Screenshot anbei. Habe die Token aus dem Login kopiert.

Log.PNG