Remove solaredge_local duplicate code (#25941)
* Removed duplicate code * Update sensor.py Splitted exceptions into two seperate ones * Update sensor.py * Update sensor.py * Update sensor.py Fixed linting errors * Update sensor.pypull/26383/head
parent
ad51615718
commit
105461edb5
|
@ -149,25 +149,19 @@ class SolarEdgeData:
|
||||||
try:
|
try:
|
||||||
response = self.api.get_status()
|
response = self.api.get_status()
|
||||||
_LOGGER.debug("response from SolarEdge: %s", response)
|
_LOGGER.debug("response from SolarEdge: %s", response)
|
||||||
|
except (ConnectTimeout):
|
||||||
self.data["energyTotal"] = response.energy.total
|
_LOGGER.error("Connection timeout, skipping update")
|
||||||
self.data["energyThisYear"] = response.energy.thisYear
|
|
||||||
self.data["energyThisMonth"] = response.energy.thisMonth
|
|
||||||
self.data["energyToday"] = response.energy.today
|
|
||||||
self.data["currentPower"] = response.powerWatt
|
|
||||||
|
|
||||||
_LOGGER.debug("Updated SolarEdge overview data: %s", self.data)
|
|
||||||
except AttributeError:
|
|
||||||
_LOGGER.error("Missing details data in solaredge response")
|
|
||||||
_LOGGER.debug("Response is: %s", response)
|
|
||||||
return
|
return
|
||||||
except (ConnectTimeout, HTTPError):
|
except (HTTPError):
|
||||||
_LOGGER.error("Could not retrieve data, skipping update")
|
_LOGGER.error("Could not retrieve data, skipping update")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
self.data["energyTotal"] = response.energy.total
|
self.data["energyTotal"] = response.energy.total
|
||||||
self.data["energyThisYear"] = response.energy.thisYear
|
self.data["energyThisYear"] = response.energy.thisYear
|
||||||
self.data["energyThisMonth"] = response.energy.thisMonth
|
self.data["energyThisMonth"] = response.energy.thisMonth
|
||||||
self.data["energyToday"] = response.energy.today
|
self.data["energyToday"] = response.energy.today
|
||||||
self.data["currentPower"] = response.powerWatt
|
self.data["currentPower"] = response.powerWatt
|
||||||
_LOGGER.debug("Updated SolarEdge overview data: %s", self.data)
|
_LOGGER.debug("Updated SolarEdge overview data: %s", self.data)
|
||||||
|
except AttributeError:
|
||||||
|
_LOGGER.error("Missing details data in SolarEdge response")
|
||||||
|
|
Loading…
Reference in New Issue