-
Notifications
You must be signed in to change notification settings - Fork 11
Description
I've started down the road of trying to integrate Delta 2 data with HA via MQTT...
I already have mosquito broker setup as per the instructions from @lwsrbrts in ISSUE #1 and my tweaks for SHP per ISSUE #5 so I simply added the following to mosquito.conf:
# Delta2 Data
topic "" in 0 ecoflow/D2/data /app/device/property/<D2 Serial Number in UPPER CASE>
After seeing the ../D2/data topic on the local broker via MQTT Explorer I used a power shell script to gather messages and log them over the course of several minutes and captured a number of short messages with 1-5 key/value pairs each similar to this:
{"id":1330299617613842767,"version":"1.0","timestamp":1669603258,"moduleType":"1","params":{"pd.carTemp":36}}
{"id":1330299618754038533,"version":"1.0","timestamp":1669603258,"moduleType":"2","params":{"bms_bmsStatus.minCellTemp":26,"bms_bmsStatus.vol":53494,"bms_bmsStatus.f32ShowSoc":89.7}}
{"id":1330299618642890337,"version":"1.0","timestamp":1669603258,"moduleType":"1","params":{"pd.carTemp":35}}
{"id":1330299626203776316,"version":"1.0","timestamp":1669603259,"moduleType":"3","params":{"inv.acInVol":123113}}
{"id":1330299627343973305,"version":"1.0","timestamp":1669603259,"moduleType":"2","params":{"bms_emsStatus.paraVolMin":52491,"bms_emsStatus.paraVolMax":54491}}
{"id":1330299627232824896,"version":"1.0","timestamp":1669603259,"moduleType":"2","params":{"bms_bmsStatus.maxCellVol":3343,"bms_bmsStatus.vol":53491,"bms_bmsStatus.f32ShowSoc":89.7}}
{"id":1330299634793709708,"version":"1.0","timestamp":1669603260,"moduleType":"5","params":{"mppt.carOutVol":46,"mppt.outVol":53331,"mppt.carTemp":36}}
{"id":1330299635933905399,"version":"1.0","timestamp":1669603260,"moduleType":"1","params":{"pd.carTemp":36}}
{"id":1330299635822756850,"version":"1.0","timestamp":1669603260,"moduleType":"3","params":{"inv.acInAmp":66,"inv.acInVol":123084}}
{"id":1330299634793710818,"version":"1.0","timestamp":1669603260,"moduleType":"1","params":{"pd.carTemp":35}}
{"id":1330299687473516144,"version":"1.0","timestamp":1669603266,"moduleType":"1","params":{"pd.carTemp":35}}
{"id":1330299695952298376,"version":"1.0","timestamp":1669603267,"moduleType":"2","params":{"bms_bmsStatus.vol":53490,"bms_bmsStatus.f32ShowSoc":89.7,"bms_bmsStatus.minCellVol":3342}}
{"id":1330299694923253762,"version":"1.0","timestamp":1669603267,"moduleType":"1","params":{"pd.carTemp":36}}
{"id":1330299696063449385,"version":"1.0","timestamp":1669603267,"moduleType":"5","params":{"mppt.carOutVol":46,"mppt.inVol":942,"mppt.outVol":53331,"mppt.carTemp":36}}
{"id":1330299695952300772,"version":"1.0","timestamp":1669603267,"moduleType":"3","params":{"inv.acInAmp":74,"inv.acInVol":123504}}
{"id":1330299747603057983,"version":"1.0","timestamp":1669603273,"moduleType":"1","params":{"pd.carTemp":36}}
{"id":1330299756081840390,"version":"1.0","timestamp":1669603274,"moduleType":"2","params":{"bms_emsStatus.f32LcdShowSoc":89.7,"bms_emsStatus.paraVolMin":52494,"bms_emsStatus.paraVolMax":54494}}
{"id":1330299755052794531,"version":"1.0","timestamp":1669603274,"moduleType":"2","params":{"bms_bmsStatus.remainCap":9626,"bms_bmsStatus.minCellTemp":26,"bms_bmsStatus.vol":53490,"bms_bmsStatus.f32ShowSoc":89.7}}
{"id":1330299756192990623,"version":"1.0","timestamp":1669603274,"moduleType":"1","params":{"pd.carTemp":35}}
After parsing and sorting a bit I came up with the following list of "unique" params:
bms_bmsStatus.amp
bms_bmsStatus.f32ShowSoc
bms_bmsStatus.maxCellVol
bms_bmsStatus.minCellTemp
bms_bmsStatus.minCellVol
bms_bmsStatus.remainCap
bms_bmsStatus.vol
bms_emsStatus.f32LcdShowSoc
bms_emsStatus.paraVolMax
bms_emsStatus.paraVolMin
inv.acInAmp
inv.acInVol
mppt.carOutVol
mppt.carTemp
mppt.inAmp
mppt.inVol
mppt.outVol
pd.carTemp
I also grabbed the payload from ..\get_reply in response to "lastestquotas" from the EF MQTT server (sent to ..\get by the D2 app when it opens) and discovered these unique keys:
bms_bmsStatus.amp
bms_bmsStatus.bmsFault
bms_bmsStatus.bqSysStatReg
bms_bmsStatus.cellId
bms_bmsStatus.cycles
bms_bmsStatus.designCap
bms_bmsStatus.errCode
bms_bmsStatus.f32ShowSoc
bms_bmsStatus.fullCap
bms_bmsStatus.inputWatts
bms_bmsStatus.maxCellTemp
bms_bmsStatus.maxCellVol
bms_bmsStatus.maxMosTemp
bms_bmsStatus.minCellTemp
bms_bmsStatus.minCellVol
bms_bmsStatus.minMosTemp
bms_bmsStatus.num
bms_bmsStatus.openBmsIdx
bms_bmsStatus.outputWatts
bms_bmsStatus.remainCap
bms_bmsStatus.remainTime
bms_bmsStatus.soc
bms_bmsStatus.soh
bms_bmsStatus.sysVer
bms_bmsStatus.tagChgAmp
bms_bmsStatus.temp
bms_bmsStatus.type
bms_bmsStatus.vol
bms_emsStatus.bmsIsConnt
bms_emsStatus.bmsModel
bms_emsStatus.bmsWarState
bms_emsStatus.chgAmp
bms_emsStatus.chgCmd
bms_emsStatus.chgRemainTime
bms_emsStatus.chgState
bms_emsStatus.chgVol
bms_emsStatus.dsgCmd
bms_emsStatus.dsgRemainTime
bms_emsStatus.emsIsNormalFlag
bms_emsStatus.f32LcdShowSoc
bms_emsStatus.fanLevel
bms_emsStatus.lcdShowSoc
bms_emsStatus.maxAvailNum
bms_emsStatus.maxChargeSoc
bms_emsStatus.maxCloseOilEb
bms_emsStatus.minDsgSoc
bms_emsStatus.minOpenOilEb
bms_emsStatus.openBmsIdx
bms_emsStatus.openUpsFlag
bms_emsStatus.paraVolMax
bms_emsStatus.paraVolMin
inv.acDipSwitch
inv.acInAmp
inv.acInFreq
inv.acInVol
inv.cfgAcEnabled
inv.cfgAcOutFreq
inv.cfgAcOutVol
inv.cfgAcWorkMode
inv.cfgAcXboost
inv.chargerType
inv.chgPauseFlag
inv.dcInAmp
inv.dcInTemp
inv.dcInVol
inv.dischargeType
inv.errCode
inv.fanState
inv.FastChgWatts
inv.inputWatts
inv.invOutAmp
inv.invOutFreq
inv.invOutVol
inv.invType
inv.outputWatts
inv.outTemp
inv.reserved
inv.SlowChgWatts
inv.standbyMins
inv.sysVer
mppt.acStandbyMins
mppt.beepState
mppt.carOutAmp
mppt.carOutVol
mppt.carOutWatts
mppt.carStandbyMin
mppt.carState
mppt.carTemp
mppt.cfgAcEnabled
mppt.cfgAcOutFreq
mppt.cfgAcOutVol
mppt.cfgAcXboost
mppt.cfgChgType
mppt.cfgChgWatts
mppt.chgPauseFlag
mppt.chgState
mppt.chgType
mppt.dc24vState
mppt.dc24vTemp
mppt.dcChgCurrent
mppt.dcdc12vAmp
mppt.dcdc12vVol
mppt.dcdc12vWatts
mppt.dischargeType
mppt.faultCode
mppt.inAmp
mppt.inVol
mppt.inWatts
mppt.mpptTemp
mppt.outAmp
mppt.outVol
mppt.outWatts
mppt.powStandbyMin
mppt.res
mppt.scrStandbyMin
mppt.swVer
mppt.x60ChgType
pd.beepMode
pd.brightLevel
pd.carState
pd.carTemp
pd.carUsedTime
pd.carWatts
pd.chgDsgState
pd.chgPowerAC
pd.chgPowerDC
pd.chgSunPower
pd.dcInUsedTime
pd.dcOutState
pd.dsgPowerAC
pd.dsgPowerDC
pd.errCode
pd.ext3p8Port
pd.ext4p8Port
pd.extRj45Port
pd.icoBytes
pd.invUsedTime
pd.lcdOffSec
pd.model
pd.mpptUsedTime
pd.qcUsb1Watts
pd.qcUsb2Watts
pd.remainTime
pd.reserved
pd.soc
pd.standbyMin
pd.sysVer
pd.typec1Temp
pd.typec1Watts
pd.typec2Temp
pd.typec2Watts
pd.typecUsedTime
pd.usb1Watts
pd.usb2Watts
pd.usbqcUsedTime
pd.usbUsedTime
pd.wattsInSum
pd.wattsOutSum
pd.wifiAutoRcvy
pd.wifiRssi
pd.wifiVer
pd.wireWatts
It appears the D2 works differently than the DP. The DP will send a large message with the status of 'everything' for a given module (bmsMaster, ems, inv, ...) on a fairly frequent basis. SHP appears to operate in a similar way. The D2 appears to send only small messages with what seem to be status "updates" for specific data points which would seem to imply the app gets the status of 'everything' when it opens and then only receives update messages past that point... I'm still new to HA and MQTT and I'm not an "app developer" so some of my speculations here (based on initial observation) may well be incorrect...
For DP and SHP we can create automations in HA to trigger on specific payloads for specific params in messages such as "bmsMaster.errCode = 0" (for DP) or "id = 2" (for SHP) and, based on those triggers, re-publish the entire message to a unique sub-topic (such as ../SHP/circuits) then use an mqtt sensor to pull all the key/value pairs into attributes of an entity in HA. Once those attributes exist in HA custom sensors can be made to track specific attributes (such as sensor.shp_circuit_1_power) or the attribute values can be used directly in various places like {{ state_attr('sensor.shp_circuits','infoList')[10].chWatt | round(0) }}
For D2, the messages arrive with a unique "moduleType" but may contain one or several different parameters... The moduleType could be used by an automation to re-publish to a unique topic per module... but at that point I'm a bit lost in terms of how to structure mqtt sensors to pull the specific data/attributes into HA...
Perhaps someone here with more HA/MQTT background can suggest the best approach?