Allow using energymeters to meter consumers

pull/712/head
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)
{
qCritical() << "SetHiddenThingClassIds" << hiddenThingClassIds;
if (m_hiddenThingClassIds != hiddenThingClassIds) {
m_hiddenThingClassIds = hiddenThingClassIds;
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
{
return m_requiredEventName;
@ -606,6 +619,10 @@ bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_par
return false;
}
if (m_hiddenThingIds.contains(thing->id())) {
return false;
}
if (m_showDigitalInputs || m_showDigitalOutputs || m_showAnalogInputs || m_showAnalogOutputs) {
if (m_showDigitalInputs && thingClass->stateTypes()->ioStateTypes(Types::IOTypeDigitalInput).isEmpty()) {
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> 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 requiredStateName READ requiredStateName WRITE setRequiredStateName NOTIFY requiredStateNameChanged)
@ -127,6 +128,9 @@ public:
QList<QUuid> hiddenThingClassIds() const;
void setHiddenThingClassIds(const QList<QUuid> &hiddenThingClassIds);
QList<QUuid> hiddenThingIds() const;
void setHiddenThingIds(const QList<QUuid> &hiddenThingIds);
QString requiredEventName() const;
void setRequiredEventName(const QString &requiredEventName);
@ -188,6 +192,7 @@ signals:
void nameFilterChanged();
void shownThingClassIdsChanged();
void hiddenThingClassIdsChanged();
void hiddenThingIdsChanged();
void requiredEventNameChanged();
void requiredStateNameChanged();
void requiredActionNameChanged();
@ -223,6 +228,7 @@ private:
QString m_nameFilter;
QList<QUuid> m_shownThingClassIds;
QList<QUuid> m_hiddenThingClassIds;
QList<QUuid> m_hiddenThingIds;
QString m_requiredEventName;
QString m_requiredStateName;

View File

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

View File

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

View File

@ -242,10 +242,13 @@ MainPageTile {
tmp.push({iface: "gassensor", state: "gas"});
}
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) {
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) {
tmp.push({iface: "daylightsensor", state: "daylight"});

View File

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

View File

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