Allow using energymeters to meter consumers

This commit is contained in:
Michael Zanetti 2021-11-29 22:02:06 +01:00
parent 88112c1b73
commit 28265dedb1
7 changed files with 41 additions and 12 deletions

View File

@ -236,7 +236,6 @@ QList<QUuid> ThingsProxy::hiddenThingClassIds() const
void ThingsProxy::setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds) void ThingsProxy::setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds)
{ {
qCritical() << "SetHiddenThingClassIds" << hiddenThingClassIds;
if (m_hiddenThingClassIds != hiddenThingClassIds) { if (m_hiddenThingClassIds != hiddenThingClassIds) {
m_hiddenThingClassIds = hiddenThingClassIds; m_hiddenThingClassIds = hiddenThingClassIds;
emit hiddenThingClassIdsChanged(); emit hiddenThingClassIdsChanged();
@ -244,6 +243,20 @@ void ThingsProxy::setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds
} }
} }
QList<QUuid> ThingsProxy::hiddenThingIds() const
{
return m_hiddenThingIds;
}
void ThingsProxy::setHiddenThingIds(const QList<QUuid> &hiddenThingIds)
{
if (m_hiddenThingIds != hiddenThingIds) {
m_hiddenThingIds = hiddenThingIds;
emit hiddenThingIdsChanged();
invalidateFilterInternal();
}
}
QString ThingsProxy::requiredEventName() const QString ThingsProxy::requiredEventName() const
{ {
return m_requiredEventName; return m_requiredEventName;
@ -606,6 +619,10 @@ bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_par
return false; return false;
} }
if (m_hiddenThingIds.contains(thing->id())) {
return false;
}
if (m_showDigitalInputs || m_showDigitalOutputs || m_showAnalogInputs || m_showAnalogOutputs) { if (m_showDigitalInputs || m_showDigitalOutputs || m_showAnalogInputs || m_showAnalogOutputs) {
if (m_showDigitalInputs && thingClass->stateTypes()->ioStateTypes(Types::IOTypeDigitalInput).isEmpty()) { if (m_showDigitalInputs && thingClass->stateTypes()->ioStateTypes(Types::IOTypeDigitalInput).isEmpty()) {
return false; return false;

View File

@ -56,6 +56,7 @@ class ThingsProxy : public QSortFilterProxyModel
Q_PROPERTY(QList<QUuid> shownThingClassIds READ shownThingClassIds WRITE setShownThingClassIds NOTIFY shownThingClassIdsChanged) Q_PROPERTY(QList<QUuid> shownThingClassIds READ shownThingClassIds WRITE setShownThingClassIds NOTIFY shownThingClassIdsChanged)
Q_PROPERTY(QList<QUuid> hiddenThingClassIds READ hiddenThingClassIds WRITE setHiddenThingClassIds NOTIFY hiddenThingClassIdsChanged) Q_PROPERTY(QList<QUuid> hiddenThingClassIds READ hiddenThingClassIds WRITE setHiddenThingClassIds NOTIFY hiddenThingClassIdsChanged)
Q_PROPERTY(QList<QUuid> hiddenThingIds READ hiddenThingIds WRITE setHiddenThingIds NOTIFY hiddenThingIdsChanged)
Q_PROPERTY(QString requiredEventName READ requiredEventName WRITE setRequiredEventName NOTIFY requiredEventNameChanged) Q_PROPERTY(QString requiredEventName READ requiredEventName WRITE setRequiredEventName NOTIFY requiredEventNameChanged)
Q_PROPERTY(QString requiredStateName READ requiredStateName WRITE setRequiredStateName NOTIFY requiredStateNameChanged) Q_PROPERTY(QString requiredStateName READ requiredStateName WRITE setRequiredStateName NOTIFY requiredStateNameChanged)
@ -127,6 +128,9 @@ public:
QList<QUuid> hiddenThingClassIds() const; QList<QUuid> hiddenThingClassIds() const;
void setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds); void setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds);
QList<QUuid> hiddenThingIds() const;
void setHiddenThingIds(const QList<QUuid> &hiddenThingIds);
QString requiredEventName() const; QString requiredEventName() const;
void setRequiredEventName(const QString &requiredEventName); void setRequiredEventName(const QString &requiredEventName);
@ -188,6 +192,7 @@ signals:
void nameFilterChanged(); void nameFilterChanged();
void shownThingClassIdsChanged(); void shownThingClassIdsChanged();
void hiddenThingClassIdsChanged(); void hiddenThingClassIdsChanged();
void hiddenThingIdsChanged();
void requiredEventNameChanged(); void requiredEventNameChanged();
void requiredStateNameChanged(); void requiredStateNameChanged();
void requiredActionNameChanged(); void requiredActionNameChanged();
@ -223,6 +228,7 @@ private:
QString m_nameFilter; QString m_nameFilter;
QList<QUuid> m_shownThingClassIds; QList<QUuid> m_shownThingClassIds;
QList<QUuid> m_hiddenThingClassIds; QList<QUuid> m_hiddenThingClassIds;
QList<QUuid> m_hiddenThingIds;
QString m_requiredEventName; QString m_requiredEventName;
QString m_requiredStateName; QString m_requiredStateName;

View File

@ -367,9 +367,9 @@ ApplicationWindow {
case "smartmeter": case "smartmeter":
case "smartmeterconsumer": case "smartmeterconsumer":
case "smartmeterproducer": case "smartmeterproducer":
return Qt.resolvedUrl("images/smartmeter.svg")
case "energymeter": case "energymeter":
return Qt.resolvedUrl("images/energy.svg") return Qt.resolvedUrl("images/smartmeter.svg")
// return Qt.resolvedUrl("images/energy.svg")
case "heating": case "heating":
return Qt.resolvedUrl("images/thermostat/heating.svg") return Qt.resolvedUrl("images/thermostat/heating.svg")
case "cooling": case "cooling":

View File

@ -323,8 +323,8 @@ MainPageTile {
ListElement { ifaceName: "gassensor"; stateName: "gas" } ListElement { ifaceName: "gassensor"; stateName: "gas" }
ListElement { ifaceName: "conductivity"; stateName: "conductivity" } ListElement { ifaceName: "conductivity"; stateName: "conductivity" }
ListElement { ifaceName: "noisesensor"; stateName: "noise" } ListElement { ifaceName: "noisesensor"; stateName: "noise" }
ListElement { ifaceName: "smartmeterconsumer"; stateName: "totalEnergyConsumed" } ListElement { ifaceName: "smartmeterconsumer"; stateName: "currentPower" }
ListElement { ifaceName: "smartmeterproducer"; stateName: "totalEnergyProduced" } ListElement { ifaceName: "smartmeterproducer"; stateName: "currentPower" }
ListElement { ifaceName: "energymeter"; stateName: "currentPower" } ListElement { ifaceName: "energymeter"; stateName: "currentPower" }
ListElement { ifaceName: "thermostat"; stateName: "targetTemperature" } ListElement { ifaceName: "thermostat"; stateName: "targetTemperature" }
ListElement { ifaceName: "heating"; stateName: "power" } ListElement { ifaceName: "heating"; stateName: "power" }

View File

@ -242,10 +242,13 @@ MainPageTile {
tmp.push({iface: "gassensor", state: "gas"}); tmp.push({iface: "gassensor", state: "gas"});
} }
if (thing.thingClass.interfaces.indexOf("smartmeterconsumer") >= 0) { if (thing.thingClass.interfaces.indexOf("smartmeterconsumer") >= 0) {
tmp.push({iface: "smartmeterconsumer", state: "totalEnergyConsumed"}); tmp.push({iface: "smartmeterconsumer", state: "currentPower"});
} }
if (thing.thingClass.interfaces.indexOf("smartmeterproducer") >= 0) { if (thing.thingClass.interfaces.indexOf("smartmeterproducer") >= 0) {
tmp.push({iface: "smartmeterproducer", state: "totalEnergyProduced"}); tmp.push({iface: "smartmeterproducer", state: "currentPower"});
}
if (thing.thingClass.interfaces.indexOf("energymeter") >= 0) {
tmp.push({iface: "energymeter", state: "currentPower"});
} }
if (thing.thingClass.interfaces.indexOf("daylightsensor") >= 0) { if (thing.thingClass.interfaces.indexOf("daylightsensor") >= 0) {
tmp.push({iface: "daylightsensor", state: "daylight"}); tmp.push({iface: "daylightsensor", state: "daylight"});

View File

@ -73,8 +73,9 @@ MainViewBase {
ThingsProxy { ThingsProxy {
id: consumers id: consumers
engine: _engine engine: _engine
shownInterfaces: ["smartmeterconsumer"] shownInterfaces: ["smartmeterconsumer", "energymeter"]
hideTagId: "hiddenInEnergyView" hideTagId: "hiddenInEnergyView"
hiddenThingIds: [energyManager.rootMeterId]
} }
ThingsProxy { ThingsProxy {

View File

@ -10,6 +10,11 @@ SettingsPageBase {
property EnergyManager energyManager: null property EnergyManager energyManager: null
property ThingsProxy allConsumers: ThingsProxy {
engine: _engine
shownInterfaces: ["smartmeterconsumer", "energymeter"]
hiddenThingIds: [energyManager.rootMeterId]
}
SettingsPageSectionHeader { SettingsPageSectionHeader {
@ -57,10 +62,7 @@ SettingsPageBase {
} }
Repeater { Repeater {
model: ThingsProxy { model: root.allConsumers
engine: _engine
shownInterfaces: ["smartmeterconsumer"]
}
delegate: CheckDelegate { delegate: CheckDelegate {
Layout.fillWidth: true Layout.fillWidth: true
text: model.name text: model.name