Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged

0.107.3 #33054

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions homeassistant/components/netatmo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .const import (
AUTH,
CONF_CLOUDHOOK_URL,
DATA_DEVICE_IDS,
DATA_PERSONS,
DOMAIN,
OAUTH2_AUTHORIZE,
Expand Down Expand Up @@ -65,6 +66,7 @@ async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Netatmo component."""
hass.data[DOMAIN] = {}
hass.data[DOMAIN][DATA_PERSONS] = {}
hass.data[DOMAIN][DATA_DEVICE_IDS] = {}

if DOMAIN not in config:
return True
Expand Down Expand Up @@ -104,14 +106,17 @@ async def unregister_webhook(event):
webhook_unregister(hass, entry.data[CONF_WEBHOOK_ID])

async def register_webhook(event):
# Wait for the could integration to be ready
# Wait for the cloud integration to be ready
await asyncio.sleep(WAIT_FOR_CLOUD)

if CONF_WEBHOOK_ID not in entry.data:
data = {**entry.data, CONF_WEBHOOK_ID: secrets.token_hex()}
hass.config_entries.async_update_entry(entry, data=data)

if hass.components.cloud.async_active_subscription():
# Wait for cloud connection to be established
await asyncio.sleep(WAIT_FOR_CLOUD)

if CONF_CLOUDHOOK_URL not in entry.data:
webhook_url = await hass.components.cloud.async_create_cloudhook(
entry.data[CONF_WEBHOOK_ID]
Expand Down Expand Up @@ -144,6 +149,11 @@ async def register_webhook(event):

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
if CONF_WEBHOOK_ID in entry.data:
await hass.async_add_executor_job(
hass.data[DOMAIN][entry.entry_id][AUTH].dropwebhook
)

unload_ok = all(
await asyncio.gather(
*[
Expand All @@ -152,14 +162,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
]
)
)

if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)

if CONF_WEBHOOK_ID in entry.data:
await hass.async_add_executor_job(
hass.data[DOMAIN][entry.entry_id][AUTH].dropwebhook()
)

return unload_ok


Expand Down
12 changes: 0 additions & 12 deletions homeassistant/components/netatmo/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,11 @@ def __init__(self, data, camera_id, camera_type, verify_ssl, quality):
self._unique_id = f"{self._camera_id}-{self._camera_type}"
self._verify_ssl = verify_ssl
self._quality = quality

# URLs
self._vpnurl = None
self._localurl = None

# Monitoring status
self._status = None

# SD Card status
self._sd_status = None

# Power status
self._alim_status = None

# Is local
self._is_local = None

def camera_image(self):
Expand Down Expand Up @@ -219,8 +209,6 @@ def unique_id(self):

def update(self):
"""Update entity status."""

# Refresh camera data
self._data.update()

camera = self._data.camera_data.get_camera(cid=self._camera_id)
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/netatmo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ def setup(self):
except TypeError:
_LOGGER.error("ThermostatData::setup() got error")
return False
except pyatmo.exceptions.NoDevice:
_LOGGER.debug(
"No climate devices for %s (%s)", self.home_name, self.home_id
)
return False
return True

@Throttle(MIN_TIME_BETWEEN_UPDATES)
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/netatmo/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def extra_authorize_data(self) -> dict:
"read_station",
"read_thermostat",
"write_camera",
"write_presence",
"write_thermostat",
]

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/netatmo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"NOC": "Smart Outdoor Camera",
"NSD": "Smart Smoke Alarm",
"NACamDoorTag": "Smart Door and Window Sensors",
"NHC": "Smart Indoor Air Quality Monitor",
"NAMain": "Smart Home Weather station – indoor module",
"NAModule1": "Smart Home Weather station – outdoor module",
"NAModule4": "Smart Additional Indoor module",
"NAModule3": "Smart Rain Gauge",
"NAModule2": "Smart Anemometer",
"NHC": "Home Coach",
}

AUTH = "netatmo_auth"
Expand All @@ -32,6 +32,7 @@
OAUTH2_AUTHORIZE = "https://api.netatmo.com/oauth2/authorize"
OAUTH2_TOKEN = "https://api.netatmo.com/oauth2/token"

DATA_DEVICE_IDS = "netatmo_device_ids"
DATA_PERSONS = "netatmo_persons"

NETATMO_WEBHOOK_URL = None
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/person/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@
)

CONFIG_SCHEMA = vol.Schema(
{vol.Optional(DOMAIN): vol.All(cv.ensure_list, cv.remove_falsy, [PERSON_SCHEMA])},
{
vol.Optional(DOMAIN, default=[]): vol.All(
cv.ensure_list, cv.remove_falsy, [PERSON_SCHEMA]
)
},
extra=vol.ALLOW_EXTRA,
)

Expand Down
4 changes: 3 additions & 1 deletion homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,9 @@ def _identify_config_schema(module: ModuleType) -> Tuple[Optional[str], Optional

schema = module.CONFIG_SCHEMA.schema[key] # type: ignore

if hasattr(key, "default"):
if hasattr(key, "default") and not isinstance(
key.default, vol.schema_builder.Undefined
):
default_value = schema(key.default())

if isinstance(default_value, dict):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 0
MINOR_VERSION = 107
PATCH_VERSION = "2"
PATCH_VERSION = "3"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (3, 7, 0)
Expand Down
1 change: 1 addition & 0 deletions tests/components/netatmo/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
"read_station",
"read_thermostat",
"write_camera",
"write_presence",
"write_thermostat",
]
)
Expand Down