Make generic car minimum charging current read only and offer settings for adjustment
This commit is contained in:
parent
32456e1e20
commit
73c19826c1
@ -264,8 +264,24 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
|||||||
thing->setStateValue(batteryBatteryCriticalStateTypeId, currentBatteryLevel <= value.toInt());
|
thing->setStateValue(batteryBatteryCriticalStateTypeId, currentBatteryLevel <= value.toInt());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (thing->thingClassId() == carThingClassId) {
|
||||||
|
// Set the min charging current state if the settings value changed
|
||||||
|
connect(thing, &Thing::settingChanged, this, [thing](const ParamTypeId ¶mTypeId, const QVariant &value){
|
||||||
|
if (paramTypeId == carSettingsMinChargingCurrentParamTypeId) {
|
||||||
|
qCDebug(dcGenericThings()) << "Car minimum charging current settings changed" << value.toUInt() << "A";
|
||||||
|
thing->setStateValue(carMinChargingCurrentStateTypeId, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Finish the setup
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
|
||||||
|
// Set the inital state value
|
||||||
|
thing->setStateValue(carMinChargingCurrentStateTypeId, thing->setting(carSettingsMinChargingCurrentParamTypeId));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fall trough, if not already finished and returned...
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,9 +915,6 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
|
|||||||
thing->setStateValue(carBatteryLevelStateTypeId, action.paramValue(carBatteryLevelActionBatteryLevelParamTypeId));
|
thing->setStateValue(carBatteryLevelStateTypeId, action.paramValue(carBatteryLevelActionBatteryLevelParamTypeId));
|
||||||
thing->setStateValue(carBatteryCriticalStateTypeId, action.paramValue(carBatteryLevelActionBatteryLevelParamTypeId).toInt() < 10);
|
thing->setStateValue(carBatteryCriticalStateTypeId, action.paramValue(carBatteryLevelActionBatteryLevelParamTypeId).toInt() < 10);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else if (action.actionTypeId() == carMinChargingCurrentActionTypeId) {
|
|
||||||
thing->setStateValue(carMinChargingCurrentStateTypeId, action.paramValue(carMinChargingCurrentActionMinChargingCurrentParamTypeId).toUInt());
|
|
||||||
info->finish(Thing::ThingErrorNoError);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||||
|
|||||||
@ -1781,6 +1781,18 @@
|
|||||||
"displayName": "Generic electric car",
|
"displayName": "Generic electric car",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
"interfaces": ["electricvehicle"],
|
"interfaces": ["electricvehicle"],
|
||||||
|
"settingsTypes": [
|
||||||
|
{
|
||||||
|
"id": "0c55516d-4285-4d02-8926-1dae03649e18",
|
||||||
|
"name": "minChargingCurrent",
|
||||||
|
"displayName": "Minimum charging current",
|
||||||
|
"type": "uint",
|
||||||
|
"unit": "Ampere",
|
||||||
|
"minValue": 6,
|
||||||
|
"maxValue": 16,
|
||||||
|
"defaultValue": 6
|
||||||
|
}
|
||||||
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "363a2a39-61b6-4109-9cd9-aca7367d12c7",
|
"id": "363a2a39-61b6-4109-9cd9-aca7367d12c7",
|
||||||
@ -1819,10 +1831,8 @@
|
|||||||
"name": "minChargingCurrent",
|
"name": "minChargingCurrent",
|
||||||
"displayName": "Minimum charging current",
|
"displayName": "Minimum charging current",
|
||||||
"displayNameEvent": "Minimum charging current changed",
|
"displayNameEvent": "Minimum charging current changed",
|
||||||
"displayNameAction": "Set minimum charging current",
|
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"unit": "Ampere",
|
"unit": "Ampere",
|
||||||
"writable": true,
|
|
||||||
"minValue": 6,
|
"minValue": 6,
|
||||||
"maxValue": 16,
|
"maxValue": 16,
|
||||||
"defaultValue": 6
|
"defaultValue": 6
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user