This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements during startup. Check if openhab system is available (#17)
* Improvements during startup. Check if openhab system is available * code styling * code style * Bugfix * Improvements during reconnection * code style
- Loading branch information
Showing
2 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* | ||
* Copyright (C) 2019 Christian Riedl <[email protected]> | ||
* Copyright (C) 2020 Andreas Mroß <[email protected]> | ||
* Copyright (C) 2020 Michael Löcher <[email protected]> | ||
* | ||
* This file is part of the YIO-Remote software project. | ||
* | ||
|
@@ -29,6 +30,7 @@ | |
#include <QSet> | ||
#include <QString> | ||
#include <QtDebug> | ||
#include <QProcess> | ||
|
||
#include "openhab_channelmappings.h" | ||
#include "yio-interface/entities/blindinterface.h" | ||
|
@@ -186,12 +188,20 @@ void OpenHAB::connect() { | |
|
||
_myEntities = m_entities->getByIntegration(integrationId()); | ||
|
||
getItems(true); | ||
|
||
|
||
_tries = 0; | ||
_userDisconnect = false; | ||
_wasDisconnected = false; | ||
_standby = false; | ||
if (QProcess::execute("curl", QStringList() << "-s" << _url) == 0) { | ||
startSse(); | ||
_pollingTimer.start(); | ||
getItems(true); | ||
setState(CONNECTED); | ||
} else { | ||
qCDebug(m_logCategory) << "openhab not reachable"; | ||
} | ||
} | ||
|
||
void OpenHAB::disconnect() { | ||
|
@@ -213,23 +223,34 @@ void OpenHAB::enterStandby() { | |
if (_sseReply->isRunning()) { | ||
_sseReply->abort(); | ||
} | ||
_pollingTimer.start(); | ||
if (QProcess::execute("curl", QStringList() << "-s" << _url) == 0) { | ||
_pollingTimer.start(); | ||
} else { | ||
qCDebug(m_logCategory) << "openhab not reachable"; | ||
} | ||
} | ||
|
||
void OpenHAB::leaveStandby() { | ||
_standby = false; | ||
|
||
_pollingTimer.stop(); | ||
startSse(); | ||
getItems(false); | ||
if (QProcess::execute("curl", QStringList() << "-s" << _url) == 0) { | ||
// _pollingTimer.stop(); | ||
startSse(); | ||
getItems(false); | ||
} else { | ||
qCDebug(m_logCategory) << "openhab not reachable"; | ||
} | ||
} | ||
|
||
void OpenHAB::jsonError(const QString& error) { | ||
qCWarning(m_logCategory) << "JSON error " << error; | ||
} | ||
|
||
void OpenHAB::onPollingTimer() { | ||
getItems(false); | ||
if (QProcess::execute("curl", QStringList() << "-s" << _url) == 0) { | ||
getItems(false); | ||
} else { | ||
qCDebug(m_logCategory) << "openhab not reachable"; | ||
} | ||
} | ||
|
||
void OpenHAB::onNetWorkAccessible(QNetworkAccessManager::NetworkAccessibility accessibility) { | ||
|
@@ -255,7 +276,6 @@ void OpenHAB::getItems(bool first) { | |
// called during connect | ||
setState(CONNECTED); | ||
// connect to the SSE source | ||
startSse(); | ||
} | ||
processItems(doc, first); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* | ||
* Copyright (C) 2019 Christian Riedl <[email protected]> | ||
* Copyright (C) 2020 Andreas Mroß <[email protected]> | ||
* Copyright (C) 2020 Michael Löcher <[email protected]> | ||
* | ||
* This file is part of the YIO-Remote software project. | ||
* | ||
|
e0a77bc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use conventional commit messages when squashing pull requests to get a proper change log in the next release ;-)
Supported prefixes: