mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Netatmo: Hotfix for hass 0.29 (#3576)
Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>
This commit is contained in:
parent
7d86fb8c72
commit
dd551cf056
@ -36,10 +36,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"""Setup access to Netatmo Welcome cameras."""
|
"""Setup access to Netatmo Welcome cameras."""
|
||||||
netatmo = get_component('netatmo')
|
netatmo = get_component('netatmo')
|
||||||
home = config.get(CONF_HOME)
|
home = config.get(CONF_HOME)
|
||||||
data = WelcomeData(netatmo.NETATMO_AUTH, home)
|
import lnetatmo
|
||||||
|
try:
|
||||||
|
data = WelcomeData(netatmo.NETATMO_AUTH, home)
|
||||||
|
except lnetatmo.NoDevice:
|
||||||
|
return None
|
||||||
|
|
||||||
for camera_name in data.get_camera_names():
|
for camera_name in data.get_camera_names():
|
||||||
if CONF_CAMERAS in config:
|
if config[CONF_CAMERAS] != []:
|
||||||
if camera_name not in config[CONF_CAMERAS]:
|
if camera_name not in config[CONF_CAMERAS]:
|
||||||
continue
|
continue
|
||||||
add_devices([WelcomeCamera(data, camera_name, home)])
|
add_devices([WelcomeCamera(data, camera_name, home)])
|
||||||
@ -49,7 +53,7 @@ class WelcomeCamera(Camera):
|
|||||||
"""Representation of the images published from Welcome camera."""
|
"""Representation of the images published from Welcome camera."""
|
||||||
|
|
||||||
def __init__(self, data, camera_name, home):
|
def __init__(self, data, camera_name, home):
|
||||||
"""Setup for access to the BloomSky camera images."""
|
"""Setup for access to the Netatmo camera images."""
|
||||||
super(WelcomeCamera, self).__init__()
|
super(WelcomeCamera, self).__init__()
|
||||||
self._data = data
|
self._data = data
|
||||||
self._camera_name = camera_name
|
self._camera_name = camera_name
|
||||||
|
@ -21,7 +21,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
ATTR_MODULE = 'modules'
|
ATTR_MODULE = 'modules'
|
||||||
|
|
||||||
CONF_MODULES = 'modules'
|
CONF_MODULES = 'modules'
|
||||||
CONF_MODULE_NAME = 'module_name'
|
|
||||||
CONF_STATION = 'station'
|
CONF_STATION = 'station'
|
||||||
|
|
||||||
DEPENDENCIES = ['netatmo']
|
DEPENDENCIES = ['netatmo']
|
||||||
@ -50,7 +49,7 @@ SENSOR_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MODULE_SCHEMA = vol.Schema({
|
MODULE_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_MODULE_NAME, default=[]):
|
vol.Required(cv.string, default=[]):
|
||||||
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
|
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -84,11 +83,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class NetAtmoSensor(Entity):
|
class NetAtmoSensor(Entity):
|
||||||
"""Implementation of a NetAtmo sensor."""
|
"""Implementation of a Netatmo sensor."""
|
||||||
|
|
||||||
def __init__(self, netatmo_data, module_name, sensor_type):
|
def __init__(self, netatmo_data, module_name, sensor_type):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._name = 'NetAtmo {} {}'.format(module_name,
|
self._name = 'Netatmo {} {}'.format(module_name,
|
||||||
SENSOR_TYPES[sensor_type][0])
|
SENSOR_TYPES[sensor_type][0])
|
||||||
self.netatmo_data = netatmo_data
|
self.netatmo_data = netatmo_data
|
||||||
self.module_name = module_name
|
self.module_name = module_name
|
||||||
@ -232,7 +231,7 @@ class NetAtmoData(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Call the NetAtmo API to update the data."""
|
"""Call the Netatmo API to update the data."""
|
||||||
import lnetatmo
|
import lnetatmo
|
||||||
dev_list = lnetatmo.DeviceList(self.auth)
|
dev_list = lnetatmo.DeviceList(self.auth)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user