Skip to content

Commit

Permalink
Merge branch 'master' into alarm_systems_1
Browse files Browse the repository at this point in the history
  • Loading branch information
manup committed Aug 1, 2021
2 parents 8ab0aee + 36891a1 commit 22809c1
Show file tree
Hide file tree
Showing 20 changed files with 324 additions and 283 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/device-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ assignees: ''
---

<!--
!!!!! READ THIS FIRST: https://forum.phoscon.de/t/read-me-device-request-read-me/23/2 !!!!!!
- Before requesting a device, please make sure to search the open and closed issues for any requests in the past.
- Make sure not to remove any headers and fill the template completely. If you remove the headers, the issue will be auto-closed.
- Sometimes devices have been requested before but are not implemented yet due to various reasons.
Expand Down
44 changes: 0 additions & 44 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

59 changes: 0 additions & 59 deletions .github/ISSUE_TEMPLATE/user-question.md

This file was deleted.

22 changes: 11 additions & 11 deletions .github/issue-close-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ issueConfigs:
# Example 2: Device Request
- "Device"
- "Screenshots"
- content:
#- content:
# Example 3: Feature Request
- "Feature request type"
- "Description"
- "Considered alternatives"
- "Additional context"
- content:
#- "Feature request type"
# - "Description"
# - "Considered alternatives"
# - "Additional context"
#- content:
# Example 4: User Question
- "Describe the question or issue you are having"
- "Screenshots"
- "Environment"
- "deCONZ Logs"
- "Additional context"
# - "Describe the question or issue you are having"
#- "Screenshots"
# - "Environment"
# - "deCONZ Logs"
# - "Additional context"
# The issue is judged to be legal if it includes all keywords from any of these configs.
# Or it will be closed by the app.
52 changes: 49 additions & 3 deletions database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ void DeRestPluginPrivate::checkDbUserVersion()
updated = upgradeDbToUserVersion7();
}
else if (userVersion == 7)
{
updated = upgradeDbToUserVersion8();
}
else if (userVersion == 8)
{
// latest version
}
Expand Down Expand Up @@ -500,6 +504,36 @@ bool DeRestPluginPrivate::upgradeDbToUserVersion7()
return setDbUserVersion(7);
}

/*! Upgrades database to user_version 8. */
bool DeRestPluginPrivate::upgradeDbToUserVersion8()
{
DBG_Printf(DBG_INFO, "DB upgrade to user_version 8\n");

const char *sql[] = {
"ALTER TABLE sensors add column lastseen TEXT",
"ALTER TABLE sensors add column lastannounced TEXT",
nullptr
};

for (int i = 0; sql[i] != nullptr; i++)
{
char *errmsg = nullptr;
int rc = sqlite3_exec(db, sql[i], nullptr, nullptr, &errmsg);

if (rc != SQLITE_OK)
{
if (errmsg)
{
DBG_Printf(DBG_ERROR_L2, "SQL exec failed: %s, error: %s (%d), line: %d\n", sql[i], errmsg, rc, __LINE__);
sqlite3_free(errmsg);
}
return false;
}
}

return setDbUserVersion(8);
}

#if DECONZ_LIB_VERSION >= 0x010E00
/*! Stores a source route.
Any existing source route with the same uuid will be replaced automatically.
Expand Down Expand Up @@ -3065,6 +3099,14 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
sensor.setDeletedState(Sensor::StateNormal);
}
}
else if (strcmp(colname[i], "lastseen") == 0)
{
sensor.setLastSeen(val);
}
else if (strcmp(colname[i], "lastannounced") == 0)
{
sensor.setLastAnnounced(val);
}
}
}

Expand All @@ -3085,6 +3127,8 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c

if (isClip)
{
sensor.removeItem(RAttrLastAnnounced);
sensor.removeItem(RAttrLastSeen);
ok = true;
}
// convert from old format 0x0011223344556677 to 00:11:22:33:44:55:66:77-AB where AB is the endpoint
Expand Down Expand Up @@ -3389,7 +3433,7 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
else if (sensor.type().endsWith(QLatin1String("DoorLock")))
{
clusterId = clusterId ? clusterId : DOOR_LOCK_CLUSTER_ID;

sensor.addItem(DataTypeString, RStateLockState);
sensor.addItem(DataTypeBool, RConfigLock);
}
Expand Down Expand Up @@ -5374,7 +5418,7 @@ void DeRestPluginPrivate::saveDb()
QString fingerPrintJSON = i->fingerPrint().toString();
const QString deletedState = "normal";

QString sql = QString(QLatin1String("REPLACE INTO sensors (sid, name, type, modelid, manufacturername, uniqueid, swversion, state, config, fingerprint, deletedState, mode) VALUES ('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9', '%10', '%11', '%12')"))
QString sql = QString(QLatin1String("REPLACE INTO sensors (sid, name, type, modelid, manufacturername, uniqueid, swversion, state, config, fingerprint, deletedState, mode, lastseen, lastannounced) VALUES ('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9', '%10', '%11', '%12', '%13', '%14')"))
.arg(i->id())
.arg(i->name())
.arg(i->type())
Expand All @@ -5386,7 +5430,9 @@ void DeRestPluginPrivate::saveDb()
.arg(configJSON)
.arg(fingerPrintJSON)
.arg(deletedState)
.arg(QString::number(i->mode()));
.arg(QString::number(i->mode()))
.arg(i->lastSeen())
.arg(i->lastAnnounced());

DBG_Printf(DBG_INFO_L2, "DB sql exec %s\n", qPrintable(sql));
errmsg = NULL;
Expand Down
13 changes: 0 additions & 13 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,19 +1085,6 @@ void DeRestPluginPrivate::apsdeDataIndication(const deCONZ::ApsDataIndication &i
{
Sensor *sensorNode = getSensorNodeForAddressEndpointAndCluster(ind.srcAddress(), ind.srcEndpoint(), ind.clusterId());

if (sensorNode && ind.clusterId() == IAS_ZONE_CLUSTER_ID && sensorNode->type() != QLatin1String("ZHASwitch"))
{
sensorNode = nullptr;
auto it = std::find_if(sensors.begin(), sensors.end(), [&ind](const Sensor &s) {
return s.address().ext() == ind.srcAddress().ext() && s.type() == QLatin1String("ZHASwitch");
});

if (it != sensors.end())
{
sensorNode = &*it;
}
}

if (!sensorNode)
{
// No sensorNode found for endpoint - check for multiple endpoints mapped to the same resource
Expand Down
1 change: 1 addition & 0 deletions de_web_plugin_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,7 @@ public Q_SLOTS:
bool upgradeDbToUserVersion2();
bool upgradeDbToUserVersion6();
bool upgradeDbToUserVersion7();
bool upgradeDbToUserVersion8();
void refreshDeviceDb(const deCONZ::Address &addr);
void pushZdpDescriptorDb(quint64 extAddress, quint8 endpoint, quint16 type, const QByteArray &data);
void pushZclValueDb(quint64 extAddress, quint8 endpoint, quint16 clusterId, quint16 attributeId, qint64 data);
Expand Down
9 changes: 9 additions & 0 deletions group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/

#include "event_emitter.h"
#include "group.h"
#include <QStringList>

Expand Down Expand Up @@ -125,6 +126,14 @@ bool Group::isColorLoopActive() const
return m_colorLoopActive;
}

/*! Handles admin when ResourceItem value has been set.
* \param i ResourceItem
*/
void Group::didSetValue(ResourceItem *i)
{
enqueueEvent(Event(RGroups, i->descriptor().suffix, id(), i));
}

/*! multiDeviceIds to string. */
const QString Group::midsToString() const
{
Expand Down
1 change: 1 addition & 0 deletions group.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Group : public Resource
void setIsOn(bool on);
void setColorLoopActive(bool colorLoopActive);
bool isColorLoopActive() const;
void didSetValue(ResourceItem *i) override;
const QString midsToString() const;
void setMidsFromString(const QString &mids);
const QString dmToString() const;
Expand Down
Loading

0 comments on commit 22809c1

Please sign in to comment.