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.py
pull/26383/head
ThaStealth 2019-09-03 17:05:23 +02:00 committed by Martin Hjelmare
parent ad51615718
commit 105461edb5
1 changed files with 8 additions and 14 deletions

View File

@ -149,25 +149,19 @@ class SolarEdgeData:
try:
response = self.api.get_status()
_LOGGER.debug("response from SolarEdge: %s", response)
except (ConnectTimeout):
_LOGGER.error("Connection timeout, skipping update")
return
except (HTTPError):
_LOGGER.error("Could not retrieve data, skipping update")
return
try:
self.data["energyTotal"] = response.energy.total
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
except (ConnectTimeout, HTTPError):
_LOGGER.error("Could not retrieve data, skipping update")
return
self.data["energyTotal"] = response.energy.total
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)
_LOGGER.error("Missing details data in SolarEdge response")