mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Supports the new Netatmo Home Coach (#18308)
* Supports the new Netatmo Home Coach * unused import * Missing docstring * Fixed pylint * pydocs * doc style
This commit is contained in:
parent
16e3ff2fec
commit
9d1b94c24a
@ -16,7 +16,7 @@ from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
REQUIREMENTS = ['pyatmo==1.2']
|
||||
REQUIREMENTS = ['pyatmo==1.3']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -52,7 +52,7 @@ def setup(hass, config):
|
||||
config[DOMAIN][CONF_USERNAME], config[DOMAIN][CONF_PASSWORD],
|
||||
'read_station read_camera access_camera '
|
||||
'read_thermostat write_thermostat '
|
||||
'read_presence access_presence')
|
||||
'read_presence access_presence read_homecoach')
|
||||
except HTTPError:
|
||||
_LOGGER.error("Unable to connect to Netatmo API")
|
||||
return False
|
||||
|
@ -304,6 +304,20 @@ class NetAtmoData:
|
||||
self.update()
|
||||
return self.data.keys()
|
||||
|
||||
def _detect_platform_type(self):
|
||||
"""Return the XXXData object corresponding to the specified platform.
|
||||
|
||||
The return can be a WeatherStationData or a HomeCoachData.
|
||||
"""
|
||||
import pyatmo
|
||||
for data_class in [pyatmo.WeatherStationData, pyatmo.HomeCoachData]:
|
||||
try:
|
||||
station_data = data_class(self.auth)
|
||||
_LOGGER.debug("%s detected!", str(data_class.__name__))
|
||||
return station_data
|
||||
except TypeError:
|
||||
continue
|
||||
|
||||
def update(self):
|
||||
"""Call the Netatmo API to update the data.
|
||||
|
||||
@ -316,12 +330,9 @@ class NetAtmoData:
|
||||
return
|
||||
|
||||
try:
|
||||
import pyatmo
|
||||
try:
|
||||
self.station_data = pyatmo.WeatherStationData(self.auth)
|
||||
except TypeError:
|
||||
_LOGGER.error("Failed to connect to NetAtmo")
|
||||
return # finally statement will be executed
|
||||
self.station_data = self._detect_platform_type()
|
||||
if not self.station_data:
|
||||
raise Exception("No Weather nor HomeCoach devices found")
|
||||
|
||||
if self.station is not None:
|
||||
self.data = self.station_data.lastData(
|
||||
|
@ -849,7 +849,7 @@ pyalarmdotcom==0.3.2
|
||||
pyarlo==0.2.2
|
||||
|
||||
# homeassistant.components.netatmo
|
||||
pyatmo==1.2
|
||||
pyatmo==1.3
|
||||
|
||||
# homeassistant.components.apple_tv
|
||||
pyatv==0.3.10
|
||||
|
Loading…
x
Reference in New Issue
Block a user