From 8167c8677cd2827f1beac39db09d3efcdbe3569e Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Tue, 5 May 2020 14:57:15 +0200 Subject: [PATCH] Avahi Monitor: added address and port --- avahimonitor/integrationpluginavahimonitor.cpp | 8 ++++++-- avahimonitor/integrationpluginavahimonitor.json | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/avahimonitor/integrationpluginavahimonitor.cpp b/avahimonitor/integrationpluginavahimonitor.cpp index ad7bf5a0..ee61eec0 100644 --- a/avahimonitor/integrationpluginavahimonitor.cpp +++ b/avahimonitor/integrationpluginavahimonitor.cpp @@ -60,7 +60,9 @@ void IntegrationPluginAvahiMonitor::setupThing(ThingSetupInfo *info) if (info->thing()->paramValue(avahiThingServiceParamTypeId).toString() == entry.name() && info->thing()->paramValue(avahiThingHostNameParamTypeId).toString() == entry.hostName()) { info->thing()->setStateValue(avahiIsPresentStateTypeId, true); - info->thing()->setStateValue(avahiLastSeenTimeStateTypeId, QDateTime::currentDateTime()); + info->thing()->setStateValue(avahiLastSeenTimeStateTypeId, QDateTime::currentDateTime().toString()); + info->thing()->setStateValue(avahiAddressStateTypeId, entry.hostAddress().toString()); + info->thing()->setStateValue(avahiPortStateTypeId, entry.port()); } } @@ -110,7 +112,9 @@ void IntegrationPluginAvahiMonitor::onServiceEntryAdded(const ZeroConfServiceEnt if (thing->paramValue(avahiThingServiceParamTypeId).toString() == serviceEntry.name() && thing->paramValue(avahiThingHostNameParamTypeId).toString() == serviceEntry.hostName()) { thing->setStateValue(avahiIsPresentStateTypeId, true); - thing->setStateValue(avahiLastSeenTimeStateTypeId, QDateTime::currentDateTime()); + thing->setStateValue(avahiLastSeenTimeStateTypeId, QDateTime::currentDateTime().toString()); + thing->setStateValue(avahiAddressStateTypeId, serviceEntry.hostAddress().toString()); + thing->setStateValue(avahiPortStateTypeId, serviceEntry.port()); } } } diff --git a/avahimonitor/integrationpluginavahimonitor.json b/avahimonitor/integrationpluginavahimonitor.json index df34ddf0..df1450c7 100644 --- a/avahimonitor/integrationpluginavahimonitor.json +++ b/avahimonitor/integrationpluginavahimonitor.json @@ -48,6 +48,22 @@ "type": "int", "unit": "UnixTime", "defaultValue": 0 + }, + { + "id": "db04b1ce-bc05-48b8-8012-bab97f3d0728", + "name": "address", + "displayName": "IP address", + "displayNameEvent": "IP address changed", + "type": "QString", + "defaultValue": "0.0.0.0" + }, + { + "id": "e98a4d9e-92e0-4d84-adf9-2693cf2cd714", + "name": "port", + "displayName": "Port", + "displayNameEvent": "Port changed", + "type": "int", + "defaultValue": "0" } ] }