Merge PR #667: New plugin: Notify.Events
commit
632aaabe8c
|
|
@ -396,6 +396,15 @@ Description: nymea integration plugin for myStrom devices
|
|||
This package will add support for myStrom devices to nymea.
|
||||
|
||||
|
||||
Package: nymea-plugin-nanoleaf
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
Conflicts: nymea-plugins-translations (< 1.0.1)
|
||||
Description: nymea integration plugin for nanoleaf
|
||||
This package contains the nymea integration plugin for nanoleaf devices.
|
||||
|
||||
|
||||
Package: nymea-plugin-neatobotvac
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
|
|
@ -417,15 +426,6 @@ Description: nymea integration plugin for netatmo
|
|||
This package contains the nymea integration plugin for the netatmo weather station.
|
||||
|
||||
|
||||
Package: nymea-plugin-nanoleaf
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
Conflicts: nymea-plugins-translations (< 1.0.1)
|
||||
Description: nymea integration plugin for nanoleaf
|
||||
This package contains the nymea integration plugin for nanoleaf devices.
|
||||
|
||||
|
||||
Package: nymea-plugin-networkdetector
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
|
|
@ -436,6 +436,14 @@ Description: nymea integration plugin for networkdetector
|
|||
network devices via basic networking mechanisms (ARP, ICMP..).
|
||||
|
||||
|
||||
Package: nymea-plugin-notifyevents
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
Description: nymea integration plugin for Notify.Events
|
||||
This package contains the nymea integration plugin for Notify.Events.
|
||||
|
||||
|
||||
Package: nymea-plugin-nuki
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_integrationpluginnotifyevents.so
|
||||
notifyevents/translations/*qm usr/share/nymea/translations/
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Notify.Events
|
||||
|
||||
This plugin allows to send messages to the Notify.Events service which in turn allows to distribute
|
||||
the messages to various receivers, such as instant messengers, email, push notifications and more.
|
||||
|
||||
## Requirements
|
||||
|
||||
First go to Notify.Events and sign up. Create a new channel. In the channel, add a new message source and
|
||||
select nymea. Copy the token.
|
||||
Set up a new Notify.Events thing in nymea, providing the token for the channel. Multiple things may be set
|
||||
up to send messages to different channels.
|
||||
|
||||
At this point nymea can send messages to Notify.Events which will be redistributed to all receivers configured
|
||||
on Notify.Events for this channel.
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2023, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU Lesser General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; version 3. This project is distributed in the hope that
|
||||
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "integrationpluginnotifyevents.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <network/networkaccessmanager.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QUrlQuery>
|
||||
|
||||
IntegrationPluginNotfyEvents::IntegrationPluginNotfyEvents(QObject* parent): IntegrationPlugin (parent)
|
||||
{
|
||||
}
|
||||
|
||||
IntegrationPluginNotfyEvents::~IntegrationPluginNotfyEvents()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IntegrationPluginNotfyEvents::setupThing(ThingSetupInfo *info)
|
||||
{
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
void IntegrationPluginNotfyEvents::executeAction(ThingActionInfo *info)
|
||||
{
|
||||
Thing *thing = info->thing();
|
||||
Action action = info->action();
|
||||
|
||||
qCDebug(dcNotifyEvents()) << "Executing action" << action.actionTypeId() << "for" << thing->name() << thing->id().toString();
|
||||
|
||||
QString token = thing->paramValue(notifyEventsThingTokenParamTypeId).toString();
|
||||
QString title = action.param(notifyEventsNotifyActionTitleParamTypeId).value().toString();
|
||||
QString body = action.param(notifyEventsNotifyActionBodyParamTypeId).value().toString();
|
||||
|
||||
QUrlQuery query;
|
||||
query.addQueryItem("title", title);
|
||||
query.addQueryItem("content", body);
|
||||
query.addQueryItem("level", "info");
|
||||
query.addQueryItem("priority", "normal");
|
||||
|
||||
QString url = QString("https://notify.events/api/v1/channel/source/%1/execute").arg(token);
|
||||
QNetworkRequest request((QUrl(url)));
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
|
||||
qCDebug(dcNotifyEvents()) << "Sending notification" << request.url().toString() << query.toString();
|
||||
foreach (const QByteArray &headerName, request.rawHeaderList()) {
|
||||
qCDebug(dcNotifyEvents()) << "Header:" << headerName << request.rawHeader(headerName);
|
||||
}
|
||||
// QNetworkReply *reply = hardwareManager()->networkManager()->post(request, QJsonDocument::fromVariant(data).toJson(QJsonDocument::Compact));
|
||||
QNetworkReply *reply = hardwareManager()->networkManager()->post(request, query.toString().toUtf8());
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, info, [reply, info]{
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
qCWarning(dcNotifyEvents()) << "Notify.Events message sending failed for" << info->thing()->name() << info->thing()->id() << reply->errorString() << reply->error();
|
||||
emit info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray data = reply->readAll();
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcNotifyEvents()) << "Error reading reply from server for" << info->thing()->name() << info->thing()->id().toString() << error.errorString();
|
||||
qCWarning(dcNotifyEvents()) << qUtf8Printable(data);
|
||||
info->finish(Thing::ThingErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
QVariantMap replyMap = jsonDoc.toVariant().toMap();
|
||||
qDebug(dcNotifyEvents()) << qUtf8Printable(jsonDoc.toJson());
|
||||
|
||||
|
||||
qCDebug(dcNotifyEvents()) << "Message sent successfully";
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2023, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU Lesser General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; version 3. This project is distributed in the hope that
|
||||
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef INTEGRATIONPLUGINNOTIFYEVENTS_H
|
||||
#define INTEGRATIONPLUGINNOTIFYEVENTS_H
|
||||
|
||||
#include <integrations/integrationplugin.h>
|
||||
|
||||
#include "extern-plugininfo.h"
|
||||
|
||||
class IntegrationPluginNotfyEvents: public IntegrationPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginnotifyevents.json")
|
||||
Q_INTERFACES(IntegrationPlugin)
|
||||
|
||||
public:
|
||||
explicit IntegrationPluginNotfyEvents(QObject *parent = nullptr);
|
||||
~IntegrationPluginNotfyEvents() override;
|
||||
|
||||
void setupThing(ThingSetupInfo *info) override;
|
||||
void executeAction(ThingActionInfo *info) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"displayName": "Notify.Events",
|
||||
"name": "notifyEvents",
|
||||
"id": "9f3eb18a-eb59-433f-9d03-cc974756fd21",
|
||||
"vendors": [
|
||||
{
|
||||
"displayName": "Notify.Events",
|
||||
"name": "notifyEvents",
|
||||
"id": "6089baa5-e61a-41f0-abe1-a283c6dce316",
|
||||
"thingClasses": [
|
||||
{
|
||||
"id": "e9276f0b-4194-4c4f-b0c1-b696fa15e6ff",
|
||||
"name": "notifyEvents",
|
||||
"displayName": "Notify.Events",
|
||||
"createMethods": ["user"],
|
||||
"interfaces": ["notifications"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "643a76de-d5ad-43f3-a40d-7c215eea845b",
|
||||
"name": "token",
|
||||
"displayName": "token",
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "aa3ec7aa-4490-49e0-91aa-0b0891beb316",
|
||||
"name": "notify",
|
||||
"displayName": "Send notification",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "98135099-2236-4456-99ce-81b106381430",
|
||||
"name": "title",
|
||||
"displayName": "Title",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": ""
|
||||
},
|
||||
{
|
||||
"id": "394c75d3-9a9a-4da3-8729-e93be0a86813",
|
||||
"name": "body",
|
||||
"displayName": "Body",
|
||||
"type": "QString",
|
||||
"inputType": "TextArea",
|
||||
"defaultValue": ""
|
||||
},
|
||||
{
|
||||
"id": "2b08b93a-95b7-418e-b9df-e446c3de65ae",
|
||||
"name": "level",
|
||||
"displayName": "Level",
|
||||
"type": "QString",
|
||||
"allowedValues": ["verbose", "info", "notice", "warning", "error", "success"],
|
||||
"defaultValue": "info"
|
||||
},
|
||||
{
|
||||
"id": "5e0568bf-f9f4-4289-a69f-52153c655b25",
|
||||
"name": "priority",
|
||||
"displayName": "Priority",
|
||||
"type": "QString",
|
||||
"allowedValues": ["lowest", "low", "normal", "high", "highest"],
|
||||
"defaultValue": "normal"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"title": "Notfiy.Events",
|
||||
"tagline": "Send notifictions via Notify.Events.",
|
||||
"icon": "notifyevents.png",
|
||||
"stability": "consumer",
|
||||
"offline": false,
|
||||
"technologies": [
|
||||
"cloud"
|
||||
],
|
||||
"categories": [
|
||||
"online-service",
|
||||
"notification"
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
|
|
@ -0,0 +1,11 @@
|
|||
include(../plugins.pri)
|
||||
|
||||
QT+= network
|
||||
|
||||
SOURCES += \
|
||||
integrationpluginnotifyevents.cpp
|
||||
|
||||
HEADERS += \
|
||||
integrationpluginnotifyevents.h
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>notifyEvents</name>
|
||||
<message>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="34"/>
|
||||
<source>Body</source>
|
||||
<extracomment>The name of the ParamType (ThingClass: notifyEvents, ActionType: notify, ID: {394c75d3-9a9a-4da3-8729-e93be0a86813})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="37"/>
|
||||
<source>Level</source>
|
||||
<extracomment>The name of the ParamType (ThingClass: notifyEvents, ActionType: notify, ID: {2b08b93a-95b7-418e-b9df-e446c3de65ae})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="40"/>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="43"/>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="46"/>
|
||||
<source>Notify.Events</source>
|
||||
<extracomment>The name of the ThingClass ({e9276f0b-4194-4c4f-b0c1-b696fa15e6ff})
|
||||
----------
|
||||
The name of the vendor ({6089baa5-e61a-41f0-abe1-a283c6dce316})
|
||||
----------
|
||||
The name of the plugin notifyEvents ({9f3eb18a-eb59-433f-9d03-cc974756fd21})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="49"/>
|
||||
<source>Priority</source>
|
||||
<extracomment>The name of the ParamType (ThingClass: notifyEvents, ActionType: notify, ID: {5e0568bf-f9f4-4289-a69f-52153c655b25})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="52"/>
|
||||
<source>Send notification</source>
|
||||
<extracomment>The name of the ActionType ({aa3ec7aa-4490-49e0-91aa-0b0891beb316}) of ThingClass notifyEvents</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="55"/>
|
||||
<source>Title</source>
|
||||
<extracomment>The name of the ParamType (ThingClass: notifyEvents, ActionType: notify, ID: {98135099-2236-4456-99ce-81b106381430})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build/nymea-plugins-Desktop-Debug/notifyevents/plugininfo.h" line="58"/>
|
||||
<source>token</source>
|
||||
<extracomment>The name of the ParamType (ThingClass: notifyEvents, Type: thing, ID: {643a76de-d5ad-43f3-a40d-7c215eea845b})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
@ -45,6 +45,7 @@ PLUGIN_DIRS = \
|
|||
nanoleaf \
|
||||
netatmo \
|
||||
networkdetector \
|
||||
notifyevents \
|
||||
nuki \
|
||||
mcp3008 \
|
||||
onewire \
|
||||
|
|
|
|||
Loading…
Reference in New Issue