Schrack: Add setting for connected phases
parent
ba922c7e7e
commit
dc23d1becb
|
|
@ -1,6 +1,6 @@
|
|||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2021, nymea GmbH
|
||||
* Copyright 2013 - 2023, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
|
|
@ -31,6 +31,8 @@
|
|||
#include "integrationpluginschrack.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <hardware/electricity.h>
|
||||
|
||||
#include "ciondiscovery.h"
|
||||
|
||||
IntegrationPluginSchrack::IntegrationPluginSchrack()
|
||||
|
|
@ -219,6 +221,14 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
|||
// To prevent running out of sync we'll "uncache" min/max values too.
|
||||
thing->setStateMinMaxValues(cionMaxChargingCurrentStateTypeId, 6, 32);
|
||||
|
||||
connect(thing, &Thing::settingChanged, this, [this, thing](const ParamTypeId ¶mTypeId, const QVariant &value){
|
||||
if (paramTypeId == cionSettingsPhasesParamTypeId) {
|
||||
qCInfo(dcSchrack()) << "The connected phases setting has changed to" << value.toString();
|
||||
updatePhaseCount(thing, value.toString());
|
||||
}
|
||||
});
|
||||
|
||||
updatePhaseCount(thing, thing->setting(cionSettingsPhasesParamTypeId).toString());
|
||||
}
|
||||
|
||||
void IntegrationPluginSchrack::postSetupThing(Thing *thing)
|
||||
|
|
@ -332,3 +342,9 @@ void IntegrationPluginSchrack::waitForActionFinish(ThingActionInfo *info, Modbus
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
void IntegrationPluginSchrack::updatePhaseCount(Thing *thing, const QString &phases)
|
||||
{
|
||||
thing->setStateValue(cionUsedPhasesStateTypeId, phases);
|
||||
thing->setStateValue(cionPhaseCountStateTypeId, Electricity::getPhaseCount(Electricity::convertPhasesFromString(phases)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2021, nymea GmbH
|
||||
* Copyright 2013 - 2023, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
|
|
@ -76,9 +76,10 @@ public:
|
|||
|
||||
private:
|
||||
void waitForActionFinish(ThingActionInfo *info, ModbusRtuReply *reply, const StateTypeId &stateTypeId, const QVariant &value);
|
||||
void updatePhaseCount(Thing *thing, const QString &phases);
|
||||
|
||||
private:
|
||||
PluginTimer *m_refreshTimer = nullptr;
|
||||
|
||||
QHash<Thing *, CionModbusRtuConnection *> m_cionConnections;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,16 @@
|
|||
"readOnly": true
|
||||
}
|
||||
],
|
||||
"settingsTypes": [
|
||||
{
|
||||
"id": "3b4f54d8-8dbf-4d72-837a-a444941e08a2",
|
||||
"name": "phases",
|
||||
"displayName": "Phases connected",
|
||||
"type": "QString",
|
||||
"allowedValues": ["A", "B", "C", "AB", "BC", "AC", "ABC"],
|
||||
"defaultValue": "A"
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "b7aa8e49-a6c0-4b48-b65e-47259686185f",
|
||||
|
|
@ -81,6 +91,23 @@
|
|||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "0115466c-449c-4a9f-81a1-2f806a51e313",
|
||||
"name": "phaseCount",
|
||||
"displayName": "Active phases",
|
||||
"type": "uint",
|
||||
"minValue": 1,
|
||||
"maxValue": 3,
|
||||
"defaultValue": 1
|
||||
},
|
||||
{
|
||||
"id": "879345c0-2c18-4b18-964b-d87363dda382",
|
||||
"name": "usedPhases",
|
||||
"displayName": "Used phases",
|
||||
"type": "QString",
|
||||
"possibleValues": ["A", "B", "C", "AB", "BC", "AC", "ABC"],
|
||||
"defaultValue": "A"
|
||||
},
|
||||
{
|
||||
"id": "33780b19-4855-4b5c-bd84-cec8400309be",
|
||||
"name": "currentVersion",
|
||||
|
|
|
|||
Loading…
Reference in New Issue