Page 1 of 1

Improve Pushsafer notification plugin

Posted: Thursday 02 March 2017 21:49
by pushsafer
Hello,

my name is kevin, iam the developer of https://www.pushsafer.com.

Is there a way to get help for improving the pushsafer notification plugin.
Unfortunately, I do not have the necessary knowledge to do this myself.

With pushsafer you can also send images in a push-notification. So my idea is to add a new html input field (absolute Image URL) to the setup page, see image. This is intended to provide the user with the possibility to display images of e.g. IP cameras or door bells directly by push notification.
Zwischenablage01.jpg
Zwischenablage01.jpg (108.83 KiB) Viewed 4568 times
This URL should be accessible locally or also from the Internet.
When domoticz call the pushsafer plugin, the image from url should be loaded and converted to an base64 encoded string. This string must transfered as the param p to the pushsafer API

I only have an php example:

Code: Select all

$image = file_get_contents('http://user:[email protected]/snapshot.cgi');
$imgtype ='jpg';
$image = 'data:image/'.$imgtype.';base64,'.base64_encode($image);
domoticz/notifications/NotificationPushsafer.cpp

Code: Select all

#include "stdafx.h"
#include "NotificationPushsafer.h"
#include "../httpclient/HTTPClient.h"
#include "../main/Logger.h"
#include "../httpclient/UrlEncode.h"

CNotificationPushsafer::CNotificationPushsafer() : CNotificationBase(std::string("pushsafer"), OPTIONS_URL_SUBJECT | OPTIONS_URL_BODY | OPTIONS_URL_PARAMS)
{
	SetupConfig(std::string("PushsaferEnabled"), &m_IsEnabled);
	SetupConfig(std::string("PushsaferAPI"), _apikey);
}

CNotificationPushsafer::~CNotificationPushsafer()
{
}

bool CNotificationPushsafer::SendMessageImplementation(
	const uint64_t Idx,
	const std::string &Name,
	const std::string &Subject,
	const std::string &Text,
	const std::string &ExtraData,
	const int Priority,
	const std::string &Sound,
	const bool bFromNotification)
{
	//send message to Pushsafer
	std::string cSubject = (Subject == Text) ? "Domoticz" : Subject;

	bool bRet;
	std::string sResult;
	std::stringstream sPostData;
	std::vector<std::string> ExtraHeaders;
	
	// Code for downloading the image from URL and encoding to a base64 string
	
	sPostData << "k=" << _apikey << "&t=" << cSubject << "&m=" << Text << "&p=" << image1 << "&p2=" << image2 << "&p3=" << image3;

	//Add the required Access Token and Content Type
	ExtraHeaders.push_back("Content-Type: application/x-www-form-urlencoded");
	
	bRet = HTTPClient::POST("https://www.pushsafer.com/api",sPostData.str(),ExtraHeaders,sResult);
	bool bSuccess = (sResult.find("\"success\":") != std::string::npos);
	if (!bSuccess)
		_log.Log(LOG_ERROR, "Pushsafer: %s", sResult.c_str());
	return (bRet && bSuccess);
}

bool CNotificationPushsafer::IsConfigured()
{
	return _apikey != "";
}
Hope someone can help me.

Kevin

Re: Improve Pushsafer notification plugin

Posted: Sunday 19 March 2017 22:07
by JeroenBosch
Hey Kevin,

Thanks for the good work!
I would like to help, but I don't have experience with domoticz.
I just started with an RF link and am still discovering.
Hope you quickly find someone who can help.

greetings Jeroen

Re: Improve Pushsafer notification plugin

Posted: Sunday 19 March 2017 22:12
by pushsafer
JeroenBosch wrote:Hey Kevin,

Thanks for the good work!
I would like to help, but I don't have experience with domoticz.
I just started with an RF link and am still discovering.
Hope you quickly find someone who can help.

greetings Jeroen
Hi Jeroen,

thanks for reply.
But i made it by my self: https://github.com/domoticz/domoticz/pull/1342
With the next release of Domoticz, you can send an image e.g. from an ip camera by https://www.pushsafer.com as a push-notification.

Regards
Kevin

Re: Improve Pushsafer notification plugin

Posted: Wednesday 22 March 2017 22:43
by JeroenBosch
That sounds great!
I'm looking forward to test it.

Regards
Jeroen

Re: Improve Pushsafer notification plugin

Posted: Thursday 30 March 2017 1:24
by free_nsc
Excellent work. I dont want to rain on your parade but one issue I see with this, is what about multi camera handling?

Ideally, you want the triggered notification to use the cameras url which we already have stored in camera settings in domoticz.
It might have been easier as should not need extra configuration fields adding in. This is the way emailed attachment is handled I believe.

Re: Improve Pushsafer notification plugin

Posted: Thursday 30 March 2017 11:36
by pushsafer
free_nsc wrote:Excellent work. I dont want to rain on your parade but one issue I see with this, is what about multi camera handling?

Ideally, you want the triggered notification to use the cameras url which we already have stored in camera settings in domoticz.
It might have been easier as should not need extra configuration fields adding in. This is the way emailed attachment is handled I believe.
Currently it is only intended for one camera.

I agree with you, but in the camera settings you can enter a still image url (like snapshot.cgi) or a video stream url like (videostream.cgi)

If you enter a video stream url, it is not possible to send a push-notification with image.

Do you have other ideas to support multible cameras?

Regards
Kevin