Some more fixes for Z-Wave

This commit is contained in:
Michael Zanetti 2022-08-08 23:52:15 +02:00
parent c17d32d835
commit 9f08f628d0
6 changed files with 73 additions and 31 deletions

View File

@ -84,12 +84,6 @@ void ZWaveManager::cancelPendingOperation(const QUuid &networkUuid)
m_engine->jsonRpcClient()->sendCommand("ZWave.CancelPendingOperation", {{"networkUuid", networkUuid}}, this, "cancelPendingOperationResponse");
}
int ZWaveManager::softResetController(const QUuid &networkUuid)
{
QVariantMap params = {{"networkUuid", networkUuid}};
return m_engine->jsonRpcClient()->sendCommand("ZWave.SoftResetController", params, this, "softResetControllerResponse");
}
int ZWaveManager::factoryResetNetwork(const QUuid &networkUuid)
{
QVariantMap params = {{"networkUuid", networkUuid}};
@ -333,6 +327,8 @@ ZWaveNode *ZWaveManager::unpackNode(const QVariantMap &nodeMap, ZWaveNode *node)
node->setVersion(nodeMap.value("version").toUInt());
node->setIsZWavePlus(nodeMap.value("isZWavePlus").toBool());
node->setIsSecure(nodeMap.value("isSecure").toBool());
node->setIsBeaming(nodeMap.value("isBeaming").toBool());
return node;

View File

@ -76,7 +76,6 @@ public:
Q_INVOKABLE int removeNetwork(const QUuid &networkUuid);
Q_INVOKABLE void addNode(const QUuid &networkUuid);
Q_INVOKABLE void cancelPendingOperation(const QUuid &networkUuid);
Q_INVOKABLE int softResetController(const QUuid &networkUuid);
Q_INVOKABLE int factoryResetNetwork(const QUuid &networkUuid);
// Q_INVOKABLE void getNodes(const QUuid &networkUuid);
Q_INVOKABLE int removeNode(const QUuid &networkUuid);

View File

@ -177,6 +177,32 @@ void ZWaveNode::setIsZWavePlus(bool isZWavePlus)
}
}
bool ZWaveNode::isSecure() const
{
return m_isSecure;
}
void ZWaveNode::setIsSecure(bool isSecure)
{
if (m_isSecure != isSecure) {
m_isSecure = isSecure;
emit isSecureChanged();
}
}
bool ZWaveNode::isBeaming() const
{
return m_isBeaming;
}
void ZWaveNode::setIsBeaming(bool isBeaming)
{
if (m_isBeaming != isBeaming) {
m_isBeaming = isBeaming;
emit isBeamingChanged();
}
}
bool ZWaveNode::reachable() const
{
return m_reachable;

View File

@ -30,6 +30,8 @@ class ZWaveNode : public QObject
Q_PROPERTY(quint16 productType READ productType NOTIFY productTypeChanged)
Q_PROPERTY(quint8 version READ version NOTIFY versionChanged)
Q_PROPERTY(bool isZWavePlus READ isZWavePlus NOTIFY isZWavePlusChanged)
Q_PROPERTY(bool isSecure READ isSecure NOTIFY isSecureChanged)
Q_PROPERTY(bool isBeaming READ isBeaming NOTIFY isBeamingChanged)
public:
enum ZWaveNodeType {
@ -191,6 +193,12 @@ public:
bool isZWavePlus() const;
void setIsZWavePlus(bool isZWavePlus);
bool isSecure() const;
void setIsSecure(bool isSecure);
bool isBeaming() const;
void setIsBeaming(bool isBeaming);
signals:
void initializedChanged();
void reachableChanged();
@ -210,6 +218,8 @@ signals:
void productTypeChanged();
void versionChanged();
void isZWavePlusChanged();
void isSecureChanged();
void isBeamingChanged();
private:
quint8 m_nodeId = 0;
@ -232,6 +242,8 @@ private:
quint16 m_productType = 0;
quint8 m_version = 0;
bool m_isZWavePlus = false;
bool m_isSecure = false;
bool m_isBeaming = false;
};
class ZWaveNodes: public QAbstractListModel

View File

@ -297,23 +297,22 @@ SettingsPageBase {
secondaryIconName: node && node.sleeping ? "/ui/images/system-suspend.svg" : ""
tertiaryIconName: {
if (!node || !node.reachable)
return "/ui/images/connections/nm-signal-00.svg"
var signalStrength = "00";
if (node.linkQuality <= 25)
return "/ui/images/connections/nm-signal-25.svg"
if (node.linkQuality <= 50)
return "/ui/images/connections/nm-signal-50.svg"
if (node.linkQuality <= 75)
return "/ui/images/connections/nm-signal-75.svg"
if (node.linkQuality <= 100)
return "/ui/images/connections/nm-signal-100.svg"
if (!node || !node.reachable) {
signalStrength = "00";
} else if (node.linkQuality <= 25) {
signalStrength = "25"
} else if (node.linkQuality <= 50) {
signalStrength = "50"
} else if (node.linkQuality <= 75) {
signalStrength = "75"
} else {
signalStrength = "100"
}
return "/ui/images/connections/nm-signal-" + signalStrength + (node.isSecure ? "-secure" : "") +".svg"
}
tertiaryIconColor: node.reachable ? Style.iconColor : Style.red
Connections {
@ -441,6 +440,26 @@ SettingsPageBase {
font: Style.smallFont
horizontalAlignment: Text.AlignRight
}
Label {
text: qsTr("Security supported:")
font: Style.smallFont
}
Label {
Layout.fillWidth: true
text: nodeInfoDialog.node.isSecure ? qsTr("Yes") : qsTr("No")
font: Style.smallFont
horizontalAlignment: Text.AlignRight
}
Label {
text: qsTr("Beaming supported:")
font: Style.smallFont
}
Label {
Layout.fillWidth: true
text: nodeInfoDialog.node.isBeaming ? qsTr("Yes") : qsTr("No")
font: Style.smallFont
horizontalAlignment: Text.AlignRight
}
Label {
text: qsTr("Signal strength:")
font: Style.smallFont

View File

@ -159,16 +159,6 @@ SettingsPageBase {
ColumnLayout {
Button {
Layout.fillWidth: true
Layout.leftMargin: app.margins
Layout.rightMargin: app.margins
text: qsTr("Reboot controller")
onClicked: {
d.pendingCommandId = root.zwaveManager.softResetController(root.network.networkUuid)
}
}
Button {
Layout.fillWidth: true
Layout.leftMargin: app.margins