various small changes
This commit is contained in:
parent
57ca8c4ad0
commit
2ea3bfb695
@ -1145,11 +1145,11 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
|
|||||||
QString stateName = topic.split('/').at(4);
|
QString stateName = topic.split('/').at(4);
|
||||||
QVariant value = payload;
|
QVariant value = payload;
|
||||||
QHash<QString, StateTypeId> stateTypeIdMap;
|
QHash<QString, StateTypeId> stateTypeIdMap;
|
||||||
stateTypeIdMap["power"] = shellyEmChannelCurrentPowerPhaseAStateTypeId;
|
stateTypeIdMap["power"] = shellyEmChannelCurrentPowerStateTypeId;
|
||||||
stateTypeIdMap["reactive_power"] = shellyEmChannelReactivePowerPhaseAStateTypeId;
|
stateTypeIdMap["reactive_power"] = shellyEmChannelReactivePowerPhaseAStateTypeId;
|
||||||
stateTypeIdMap["voltage"] = shellyEmChannelVoltagePhaseAStateTypeId;
|
stateTypeIdMap["voltage"] = shellyEmChannelVoltagePhaseAStateTypeId;
|
||||||
stateTypeIdMap["total"] = shellyEmChannelEnergyConsumedPhaseAStateTypeId;
|
stateTypeIdMap["total"] = shellyEmChannelTotalEnergyConsumedStateTypeId;
|
||||||
stateTypeIdMap["total_returned"] = shellyEmChannelEnergyProducedPhaseAStateTypeId;
|
stateTypeIdMap["total_returned"] = shellyEmChannelTotalEnergyProducedStateTypeId;
|
||||||
StateTypeId stateTypeId = stateTypeIdMap.value(stateName);
|
StateTypeId stateTypeId = stateTypeIdMap.value(stateName);
|
||||||
if (stateTypeId.isNull()) {
|
if (stateTypeId.isNull()) {
|
||||||
qCWarning(dcShelly()) << "Unhandled emeter value for channel" << channel << stateName;
|
qCWarning(dcShelly()) << "Unhandled emeter value for channel" << channel << stateName;
|
||||||
@ -1163,7 +1163,6 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
|
|||||||
foreach (Thing *child, myThings().filterByParentId(thing->id()).filterByInterface("energymeter")) {
|
foreach (Thing *child, myThings().filterByParentId(thing->id()).filterByInterface("energymeter")) {
|
||||||
ParamTypeId channelParamTypeId = channelParamTypeMap.value(child->thingClassId());
|
ParamTypeId channelParamTypeId = channelParamTypeMap.value(child->thingClassId());
|
||||||
if (child->paramValue(channelParamTypeId).toInt() == channel + 1) {
|
if (child->paramValue(channelParamTypeId).toInt() == channel + 1) {
|
||||||
//child->setStateValue(currentPowerStateTypeMap.value(child->thingClassId()), power);
|
|
||||||
child->setStateValue(stateTypeId, value.toDouble() * factor);
|
child->setStateValue(stateTypeId, value.toDouble() * factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1175,14 +1174,14 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
|
|||||||
foreach (Thing *child, myThings().filterByParentId(thing->id()).filterByInterface("energymeter")) {
|
foreach (Thing *child, myThings().filterByParentId(thing->id()).filterByInterface("energymeter")) {
|
||||||
ParamTypeId channelParamTypeId = channelParamTypeMap.value(child->thingClassId());
|
ParamTypeId channelParamTypeId = channelParamTypeMap.value(child->thingClassId());
|
||||||
if (child->paramValue(channelParamTypeId).toInt() == channel + 1) {
|
if (child->paramValue(channelParamTypeId).toInt() == channel + 1) {
|
||||||
|
double power = child->stateValue(shellyEmChannelCurrentPowerStateTypeId).toDouble();
|
||||||
double voltage = child->stateValue(shellyEmChannelVoltagePhaseAStateTypeId).toDouble();
|
double voltage = child->stateValue(shellyEmChannelVoltagePhaseAStateTypeId).toDouble();
|
||||||
if (qFuzzyCompare(voltage, 0) == false) {
|
if (qFuzzyCompare(voltage, 0) == false) {
|
||||||
double calcCurrent = child->stateValue(shellyEmChannelCurrentPowerPhaseAStateTypeId).toDouble()/voltage;
|
double calcCurrent = power/voltage;
|
||||||
child->setStateValue(shellyEmChannelCurrentPhaseAStateTypeId, calcCurrent);
|
child->setStateValue(shellyEmChannelCurrentPhaseAStateTypeId, calcCurrent);
|
||||||
} else {
|
} else {
|
||||||
child->setStateValue(shellyEmChannelCurrentPhaseAStateTypeId, 0);
|
child->setStateValue(shellyEmChannelCurrentPhaseAStateTypeId, 0);
|
||||||
}
|
}
|
||||||
double power = child->stateValue(shellyEmChannelCurrentPowerPhaseAStateTypeId).toDouble();
|
|
||||||
double reactivePower = child->stateValue(shellyEmChannelReactivePowerPhaseAStateTypeId).toDouble();
|
double reactivePower = child->stateValue(shellyEmChannelReactivePowerPhaseAStateTypeId).toDouble();
|
||||||
double root = qSqrt(power*power + reactivePower*reactivePower);
|
double root = qSqrt(power*power + reactivePower*reactivePower);
|
||||||
if (qFuzzyCompare(root, 0) == false) {
|
if (qFuzzyCompare(root, 0) == false) {
|
||||||
@ -1191,12 +1190,6 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
|
|||||||
} else {
|
} else {
|
||||||
child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, 0);
|
child->setStateValue(shellyEmChannelPowerFactorPhaseAStateTypeId, 0);
|
||||||
}
|
}
|
||||||
double grandTotal = child->stateValue(shellyEmChannelEnergyConsumedPhaseAStateTypeId).toDouble();
|
|
||||||
child->setStateValue(shellyEmChannelTotalEnergyConsumedStateTypeId, grandTotal);
|
|
||||||
double grandTotalReturned = child->stateValue(shellyEmChannelEnergyProducedPhaseAStateTypeId).toDouble();
|
|
||||||
child->setStateValue(shellyEmChannelTotalEnergyProducedStateTypeId, grandTotalReturned);
|
|
||||||
double totalPower = child->stateValue(shellyEmChannelCurrentPowerPhaseAStateTypeId).toDouble();
|
|
||||||
child->setStateValue(shellyEmChannelCurrentPowerStateTypeId, totalPower);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1404,7 +1397,7 @@ void IntegrationPluginShelly::setupShellyGateway(ThingSetupInfo *info)
|
|||||||
autoChilds.append(switch2Child);
|
autoChilds.append(switch2Child);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create 2 measurement channels for shelly em --> create separate switch child as well?
|
// Create 2 measurement channels for shelly em
|
||||||
if (info->thing()->thingClassId() == shellyEmThingClassId) {
|
if (info->thing()->thingClassId() == shellyEmThingClassId) {
|
||||||
ThingDescriptor channelChild(shellyEmChannelThingClassId, info->thing()->name() + " channel 1", QString(), info->thing()->id());
|
ThingDescriptor channelChild(shellyEmChannelThingClassId, info->thing()->name() + " channel 1", QString(), info->thing()->id());
|
||||||
channelChild.setParams(ParamList() << Param(shellyEmChannelThingChannelParamTypeId, 1));
|
channelChild.setParams(ParamList() << Param(shellyEmChannelThingChannelParamTypeId, 1));
|
||||||
|
|||||||
@ -1785,7 +1785,8 @@
|
|||||||
"name": "shellyEm",
|
"name": "shellyEm",
|
||||||
"displayName": "Shelly EM",
|
"displayName": "Shelly EM",
|
||||||
"createMethods": ["discovery"],
|
"createMethods": ["discovery"],
|
||||||
"interfaces": ["gateway", "wirelessconnectable", "update"],
|
"interfaces": ["gateway", "wirelessconnectable", "power", "update"],
|
||||||
|
"providedInterfaces": ["energymeter"],
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "e44d6880-4e54-44b0-85f5-4e035179402e",
|
"id": "e44d6880-4e54-44b0-85f5-4e035179402e",
|
||||||
@ -1888,7 +1889,7 @@
|
|||||||
"name": "shellyEmChannel",
|
"name": "shellyEmChannel",
|
||||||
"displayName": "Shelly EM Channel",
|
"displayName": "Shelly EM Channel",
|
||||||
"createMethods": ["auto"],
|
"createMethods": ["auto"],
|
||||||
"interfaces": ["energymeter"],
|
"interfaces": ["wirelessconnectable", "energymeter"],
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "b9b85416-0d48-4e71-9471-03385f8fc619",
|
"id": "b9b85416-0d48-4e71-9471-03385f8fc619",
|
||||||
@ -1935,7 +1936,7 @@
|
|||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "KiloWattHour",
|
"unit": "KiloWattHour",
|
||||||
"defaultValue": 0,
|
"defaultValue": 0,
|
||||||
"cached": false
|
"cached": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "7fe88e8f-a1c4-4e8d-a1de-9135b80bc7e3",
|
"id": "7fe88e8f-a1c4-4e8d-a1de-9135b80bc7e3",
|
||||||
@ -1945,7 +1946,7 @@
|
|||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "KiloWattHour",
|
"unit": "KiloWattHour",
|
||||||
"defaultValue": 0,
|
"defaultValue": 0,
|
||||||
"cached": false
|
"cached": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "a85041e8-a19e-4695-8404-3e3a06b1e92a",
|
"id": "a85041e8-a19e-4695-8404-3e3a06b1e92a",
|
||||||
@ -1955,18 +1956,6 @@
|
|||||||
"type": "double",
|
"type": "double",
|
||||||
"unit": "Watt",
|
"unit": "Watt",
|
||||||
"defaultValue": 0,
|
"defaultValue": 0,
|
||||||
"filter": "adaptive",
|
|
||||||
"cached": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "18b17662-43bc-45d4-9e33-35912b57bfb1",
|
|
||||||
"name": "currentPowerPhaseA",
|
|
||||||
"displayName": "Current power",
|
|
||||||
"displayNameEvent": "Current power changed",
|
|
||||||
"type": "double",
|
|
||||||
"unit": "Watt",
|
|
||||||
"defaultValue": 0,
|
|
||||||
"filter": "adaptive",
|
|
||||||
"cached": false
|
"cached": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -2009,26 +1998,6 @@
|
|||||||
"defaultValue": 0,
|
"defaultValue": 0,
|
||||||
"filter": "adaptive",
|
"filter": "adaptive",
|
||||||
"cached": false
|
"cached": false
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "cb28c99c-2f64-4b8b-83ca-e9809ecd992a",
|
|
||||||
"name": "energyConsumedPhaseA",
|
|
||||||
"displayName": "Total consumed energy",
|
|
||||||
"displayNameEvent": "Total consumed energy changed",
|
|
||||||
"type": "double",
|
|
||||||
"unit": "KiloWattHour",
|
|
||||||
"defaultValue": 0,
|
|
||||||
"cached": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "3c254d08-ca5a-4caa-a6fb-7f9d0e3ac6d6",
|
|
||||||
"name": "energyProducedPhaseA",
|
|
||||||
"displayName": "Total returned energy",
|
|
||||||
"displayNameEvent": "Total returned energy changed",
|
|
||||||
"type": "double",
|
|
||||||
"unit": "KiloWattHour",
|
|
||||||
"defaultValue": 0,
|
|
||||||
"cached": false
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actionTypes": [
|
"actionTypes": [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user