Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
macxq authored Apr 6, 2023
1 parent 2d0e978 commit 5af52a2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/foxess/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

METHOD_POST = "POST"
METHOD_GET = "GET"
DEFAULT_ENCODING = "UTF-8"


ATTR_DEVICE_SN = "deviceSN"
Expand Down Expand Up @@ -237,7 +238,7 @@ async def authAndgetToken(hass, username, hashedPassword):
"Connection": "keep-alive",
"X-Requested-With": "XMLHttpRequest"}

restAuth = RestData(hass, METHOD_POST, _ENDPOINT_AUTH, None,
restAuth = RestData(hass, METHOD_POST, _ENDPOINT_AUTH, DEFAULT_ENCODING, None,
headersAuth, None, payloadAuth, DEFAULT_VERIFY_SSL)

await restAuth.async_update()
Expand All @@ -264,7 +265,7 @@ async def authAndgetToken(hass, username, hashedPassword):

async def getAddresbook(hass, headersData, allData, deviceID,username, hashedPassword,tokenRefreshRetrys):
restAddressBook = RestData(hass, METHOD_GET, _ENDPOINT_ADDRESSBOOK +
deviceID, None, headersData, None, None, DEFAULT_VERIFY_SSL)
deviceID, DEFAULT_ENCODING, None, headersData, None, None, DEFAULT_VERIFY_SSL)
await restAddressBook.async_update()

if restAddressBook.data is None:
Expand All @@ -288,7 +289,7 @@ async def getReport(hass, headersData, allData, deviceID):
reportData = '{"deviceID":"'+deviceID+'","reportType":"day","variables":["feedin","generation","gridConsumption","chargeEnergyToTal","dischargeEnergyToTal","loads"],"queryDate":{"year":'+now.strftime(
"%Y")+',"month":'+now.strftime("%_m")+',"day":'+now.strftime("%_d")+'}}'

restReport = RestData(hass, METHOD_POST, _ENDPOINT_REPORT,
restReport = RestData(hass, METHOD_POST, _ENDPOINT_REPORT,DEFAULT_ENCODING,
None, headersData, None, reportData, DEFAULT_VERIFY_SSL)

await restReport.async_update()
Expand Down Expand Up @@ -322,6 +323,7 @@ async def getReportDailyGeneration(hass, headersData, allData, deviceID):
hass,
METHOD_POST,
_ENDPOINT_REPORT,
DEFAULT_ENCODING,
None,
headersData,
None,
Expand Down Expand Up @@ -349,7 +351,7 @@ async def getRaw(hass, headersData, allData, deviceID):
rawData = '{"deviceID":"'+deviceID+'","variables":["ambientTemperation","batChargePower","batCurrent","batDischargePower","batTemperature","batVolt","boostTemperation","chargeEnergyToTal","chargeTemperature","dischargeEnergyToTal","dspTemperature","epsCurrentR","epsCurrentS","epsCurrentT","epsPower","epsPowerR","epsPowerS","epsPowerT","epsVoltR","epsVoltS","epsVoltT","feedin","feedin2","feedinPower","generation","generationPower","gridConsumption","gridConsumption2","gridConsumptionPower","input","invBatCurrent","invBatPower","invBatVolt","invTemperation","loads","loadsPower","loadsPowerR","loadsPowerS","loadsPowerT","meterPower","meterPower2","meterPowerR","meterPowerS","meterPowerT","PowerFactor","pv1Current","pv1Power","pv1Volt","pv2Current","pv2Power","pv2Volt","pv3Current","pv3Power","pv3Volt","pv4Current","pv4Power","pv4Volt","pvPower","RCurrent","ReactivePower","RFreq","RPower","RVolt","SCurrent","SFreq","SoC","SPower","SVolt","TCurrent","TFreq","TPower","TVolt"],"timespan":"hour","beginDate":{"year":'+now.strftime(
"%Y")+',"month":'+now.strftime("%_m")+',"day":'+now.strftime("%_d")+',"hour":'+now.strftime("%_H")+'}}'

restRaw = RestData(hass, METHOD_POST, _ENDPOINT_RAW,
restRaw = RestData(hass, METHOD_POST, _ENDPOINT_RAW,DEFAULT_ENCODING,
None, headersData, None, rawData, DEFAULT_VERIFY_SSL)
await restRaw.async_update()

Expand Down

0 comments on commit 5af52a2

Please sign in to comment.