Improve Pushsafer notification plugin

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
User avatar
pushsafer
Posts: 7
Joined: Sunday 18 September 2016 22:21
Target OS: Windows
Domoticz version: 3.5877
Location: Germany
Contact:

Improve Pushsafer notification plugin

Post 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 3906 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
JeroenBosch
Posts: 2
Joined: Sunday 19 March 2017 21:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Improve Pushsafer notification plugin

Post 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
User avatar
pushsafer
Posts: 7
Joined: Sunday 18 September 2016 22:21
Target OS: Windows
Domoticz version: 3.5877
Location: Germany
Contact:

Re: Improve Pushsafer notification plugin

Post 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
JeroenBosch
Posts: 2
Joined: Sunday 19 March 2017 21:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Improve Pushsafer notification plugin

Post by JeroenBosch »

That sounds great!
I'm looking forward to test it.

Regards
Jeroen
free_nsc
Posts: 36
Joined: Friday 19 December 2014 0:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Improve Pushsafer notification plugin

Post 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.
User avatar
pushsafer
Posts: 7
Joined: Sunday 18 September 2016 22:21
Target OS: Windows
Domoticz version: 3.5877
Location: Germany
Contact:

Re: Improve Pushsafer notification plugin

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests