Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
Peakpower fixed. Got broken by api change
  • Loading branch information
djansen1987 committed Mar 10, 2023
1 parent 0b6df61 commit 8bc6e9d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions custom_components/saj_esolar/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,16 @@ async def async_update(self):
nextChartYear = add_years(today, 1).strftime('%Y')
chartYear = today.strftime('%Y')
epochmilliseconds = round(int((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds() * 1000))

url4 = f"https://fop.saj-electric.com/saj/monitor/site/getPlantDetailChart2?plantuid={plantuid}&chartDateType=1&energyType=0&clientDate={clientDate}&deviceSnArr={deviceSnArr}&chartCountType=2&previousChartDay={previousChartDay}&nextChartDay={nextChartDay}&chartDay={chartDay}&previousChartMonth={previousChartMonth}&nextChartMonth={nextChartMonth}&chartMonth={chartMonth}&previousChartYear={previousChartYear}&nextChartYear={nextChartYear}&chartYear={chartYear}&chartEnergyType=0&elecDevicesn={deviceSnArr}&_={epochmilliseconds}"
#_LOGGER.error(f"PlantCharts URL: {url4}")
url4 = f"https://fop.saj-electric.com/saj/monitor/site/getPlantDetailChart2?plantuid={plantuid}&chartDateType=1&energyType=0&clientDate={clientDate}&deviceSnArr={deviceSnArr}&chartCountType=2&previousChartDay={previousChartDay}&nextChartDay={nextChartDay}&chartDay={chartDay}&previousChartMonth={previousChartMonth}&nextChartMonth={nextChartMonth}&chartMonth={chartMonth}&previousChartYear={previousChartYear}&nextChartYear={nextChartYear}&chartYear={chartYear}&elecDevicesn=&_={epochmilliseconds}"
# _LOGGER.error(f"PlantCharts URL: {url4}")
response4 = await self._session.post(url4, headers=headers)

if response4.status != 200:
_LOGGER.error(f"{response4.url} returned {response4.status}")
return

plantcharts = await response4.json()
#_LOGGER.error(f"PlantCharts: {plantcharts}")
# _LOGGER.error(f"PlantCharts: {plantcharts}")
plantDetails.update(plantcharts)


Expand Down Expand Up @@ -1201,4 +1200,4 @@ async def async_update(self):


# -Debug- adding sensor
_LOGGER.debug(f"Device: {self._type} State: {self._state}")
_LOGGER.debug(f"Device: {self._type} State: {self._state}")

0 comments on commit 8bc6e9d

Please sign in to comment.