Schrack: Only complete the setup if reading a register actually works
parent
7c61c7ea8b
commit
c522717b17
|
|
@ -161,6 +161,16 @@
|
|||
"unit": "A",
|
||||
"defaultValue": 13,
|
||||
"access": "R"
|
||||
},
|
||||
{
|
||||
"id": "dipSwitches",
|
||||
"address": 700,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "init",
|
||||
"description": "DIP switch states",
|
||||
"access": "R"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,25 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
|||
|
||||
CionModbusRtuConnection *cionConnection = new CionModbusRtuConnection(hardwareManager()->modbusRtuResource()->getModbusRtuMaster(uuid), address, this);
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::reachableChanged, thing, [cionConnection, thing](bool reachable){
|
||||
qCDebug(dcSchrack()) << "Reachable state changed" << reachable;
|
||||
if (reachable) {
|
||||
cionConnection->initialize();
|
||||
} else {
|
||||
thing->setStateValue("connected", false);
|
||||
}
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::initializationFinished, info, [info, cionConnection](bool success){
|
||||
qCDebug(dcSchrack()) << "Initialisation finsihed" << success;
|
||||
if (success) {
|
||||
qCDebug(dcSchrack) << "DIP switche states:" << cionConnection->dipSwitches();
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
}
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::updateFinished, thing, [cionConnection, thing](){
|
||||
qCDebug(dcSchrack()) << "Update finished:" << thing->name() << cionConnection;
|
||||
});
|
||||
|
|
@ -183,7 +202,6 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
|||
thing->setStateMinMaxValues(cionMaxChargingCurrentStateTypeId, 6, 32);
|
||||
|
||||
m_cionConnections.insert(thing, cionConnection);
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
void IntegrationPluginSchrack::postSetupThing(Thing *thing)
|
||||
|
|
|
|||
Loading…
Reference in New Issue