Update battery
parent
88657c791c
commit
7c03a13d7d
|
|
@ -258,8 +258,13 @@ void IntegrationPluginKostal::postSetupThing(Thing *thing)
|
|||
}
|
||||
|
||||
qCDebug(dcKostal()) << "There is a battery connected but not set up yet. Creating a battery" << kostalConnection->batteryType();
|
||||
QString batteryName = kostalConnection->batteryManufacturer();
|
||||
if (kostalConnection->batteryModelId() != 0) {
|
||||
batteryName += " - " + QString::number(kostalConnection->batteryModelId());
|
||||
}
|
||||
|
||||
ThingClass batteryThingClass = thingClass(kostalBatteryThingClassId);
|
||||
ThingDescriptor descriptor(kostalBatteryThingClassId, kostalConnection->batteryManufacturer() + " - " + kostalConnection->batteryModelId(), QString(), thing->id());
|
||||
ThingDescriptor descriptor(kostalBatteryThingClassId, batteryName, QString::number(kostalConnection->batterySerialNumber()), thing->id());
|
||||
// No params required, all we need is the connection
|
||||
emit autoThingsAppeared(ThingDescriptors() << descriptor);
|
||||
}
|
||||
|
|
@ -408,21 +413,25 @@ void IntegrationPluginKostal::setupKostalConnection(ThingSetupInfo *info)
|
|||
if (batteryThings.count() == 1) {
|
||||
Thing *batteryThing = batteryThings.first();
|
||||
|
||||
batteryThing->setStateValue(kostalBatteryVoltageStateTypeId, kostalConnection->batteryVoltage());
|
||||
batteryThing->setStateValue(kostalBatteryTemperatureStateTypeId, kostalConnection->batteryTemperature());
|
||||
batteryThing->setStateValue(kostalBatteryBatteryLevelStateTypeId, kostalConnection->batteryStateOfCharge());
|
||||
batteryThing->setStateValue(kostalBatteryBatteryCriticalStateTypeId, kostalConnection->batteryStateOfCharge() < 5);
|
||||
batteryThing->setStateValue(kostalBatteryCapacityStateTypeId, kostalConnection->batteryWorkCapacity() / 1000.0); // kWh
|
||||
|
||||
batteryThing->setStateValue(kostalBatteryCurrentPowerStateTypeId, kostalConnection->batteryActualPower());
|
||||
if (kostalConnection->batteryActualPower() == 0) {
|
||||
// Note: this is the wrong capacity, as of now not known.
|
||||
//batteryThing->setStateValue(kostalBatteryCapacityStateTypeId, kostalConnection->batteryWorkCapacity() / 1000.0); // kWh
|
||||
|
||||
double batteryPower = -kostalConnection->batteryActualPower();
|
||||
batteryThing->setStateValue(kostalBatteryCurrentPowerStateTypeId, batteryPower);
|
||||
if (batteryPower == 0) {
|
||||
batteryThing->setStateValue(kostalBatteryChargingStateStateTypeId, "idle");
|
||||
} else if (kostalConnection->batteryActualPower() > 0) {
|
||||
} else if (batteryPower > 0) {
|
||||
batteryThing->setStateValue(kostalBatteryChargingStateStateTypeId, "discharging");
|
||||
} else if (kostalConnection->batteryActualPower() < 0) {
|
||||
} else if (batteryPower < 0) {
|
||||
batteryThing->setStateValue(kostalBatteryChargingStateStateTypeId, "charging");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update the meter if available
|
||||
Things meterThings = myThings().filterByParentId(thing->id()).filterByThingClassId(kostalMeterThingClassId);
|
||||
if (meterThings.count() == 1) {
|
||||
|
|
|
|||
|
|
@ -370,6 +370,24 @@
|
|||
"defaultValue": 0.00,
|
||||
"cached": false
|
||||
},
|
||||
{
|
||||
"id": "176420b8-64b6-42e1-beea-9ce2a12f3261",
|
||||
"name": "voltage",
|
||||
"displayName": "Voltage",
|
||||
"type": "double",
|
||||
"unit": "Volt",
|
||||
"defaultValue": 0.00,
|
||||
"cached": false
|
||||
},
|
||||
{
|
||||
"id": "47b07030-57eb-4c79-a469-87b2474eb312",
|
||||
"name": "temperature",
|
||||
"displayName": "Temperature",
|
||||
"type": "double",
|
||||
"unit": "DegreeCelsius",
|
||||
"defaultValue": 0.00,
|
||||
"cached": false
|
||||
},
|
||||
{
|
||||
"id": "98099dbd-3f66-43b3-8192-f2e3fdcd5d62",
|
||||
"name": "capacity",
|
||||
|
|
|
|||
|
|
@ -709,6 +709,34 @@
|
|||
"access": "RO"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "battery",
|
||||
"readSchedule": "update",
|
||||
"registers": [
|
||||
{
|
||||
"id": "batteryGrossCapacity",
|
||||
"address": 512,
|
||||
"size": 2,
|
||||
"type": "uint32",
|
||||
"readSchedule": "update",
|
||||
"registerType": "holdingRegister",
|
||||
"description": "Battery gross capacity",
|
||||
"unit": "Ah",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "batteryStateOfCharge",
|
||||
"address": 514,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"readSchedule": "update",
|
||||
"registerType": "holdingRegister",
|
||||
"description": "Battery SoC",
|
||||
"unit": "%",
|
||||
"access": "RO"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"registers": [
|
||||
|
|
@ -830,17 +858,6 @@
|
|||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "batteryStateOfCharge",
|
||||
"address": 514,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"readSchedule": "update",
|
||||
"registerType": "holdingRegister",
|
||||
"description": "Battery SoC",
|
||||
"unit": "%",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "batteryManufacturer",
|
||||
"address": 517,
|
||||
|
|
|
|||
Loading…
Reference in New Issue