Skip to content

Commit 6c138e2

Browse files
authored
Merge pull request #28456 from home-assistant/rc
101.2
2 parents c10e046 + 969b36a commit 6c138e2

File tree

10 files changed

+69
-24
lines changed

10 files changed

+69
-24
lines changed

homeassistant/components/abode/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
from homeassistant.helpers import config_validation as cv
2424
from homeassistant.helpers.entity import Entity
2525

26-
from .const import ATTRIBUTION, DOMAIN
26+
from .const import ATTRIBUTION, DOMAIN, DEFAULT_CACHEDB
2727

2828
_LOGGER = logging.getLogger(__name__)
2929

3030
CONF_POLLING = "polling"
3131

32-
DEFAULT_CACHEDB = "./abodepy_cache.pickle"
33-
3432
SERVICE_SETTINGS = "change_setting"
3533
SERVICE_CAPTURE_IMAGE = "capture_image"
3634
SERVICE_TRIGGER = "trigger_quick_action"

homeassistant/components/abode/config_flow.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
1111
from homeassistant.core import callback
1212

13-
from .const import DOMAIN # pylint: disable=W0611
13+
from .const import DOMAIN, DEFAULT_CACHEDB # pylint: disable=W0611
1414

1515
CONF_POLLING = "polling"
1616

@@ -42,9 +42,12 @@ async def async_step_user(self, user_input=None):
4242
username = user_input[CONF_USERNAME]
4343
password = user_input[CONF_PASSWORD]
4444
polling = user_input.get(CONF_POLLING, False)
45+
cache = self.hass.config.path(DEFAULT_CACHEDB)
4546

4647
try:
47-
await self.hass.async_add_executor_job(Abode, username, password, True)
48+
await self.hass.async_add_executor_job(
49+
Abode, username, password, True, True, True, cache
50+
)
4851

4952
except (AbodeException, ConnectTimeout, HTTPError) as ex:
5053
_LOGGER.error("Unable to connect to Abode: %s", str(ex))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
"""Constants for the Abode Security System component."""
22
DOMAIN = "abode"
33
ATTRIBUTION = "Data provided by goabode.com"
4+
5+
DEFAULT_CACHEDB = "abodepy_cache.pickle"

homeassistant/components/knx/light.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,9 @@ def should_poll(self):
180180
@property
181181
def brightness(self):
182182
"""Return the brightness of this light between 0..255."""
183-
if self.device.supports_brightness:
184-
return self.device.current_brightness
185-
if (
186-
self.device.supports_color or self.device.supports_rgbw
187-
) and self.device.current_color:
188-
return max(self.device.current_color)
189-
return None
183+
if not self.device.supports_brightness:
184+
return None
185+
return self.device.current_brightness
190186

191187
@property
192188
def hs_color(self):

homeassistant/components/plex/media_player.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import plexapi.exceptions
77
import requests.exceptions
88

9-
from homeassistant.components.media_player import MediaPlayerDevice
9+
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN, MediaPlayerDevice
1010
from homeassistant.components.media_player.const import (
1111
MEDIA_TYPE_MOVIE,
1212
MEDIA_TYPE_MUSIC,
@@ -30,6 +30,7 @@
3030
)
3131
from homeassistant.core import callback
3232
from homeassistant.helpers.dispatcher import async_dispatcher_connect
33+
from homeassistant.helpers.entity_registry import async_get_registry
3334
from homeassistant.util import dt as dt_util
3435

3536
from .const import (
@@ -56,10 +57,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
5657
async def async_setup_entry(hass, config_entry, async_add_entities):
5758
"""Set up Plex media_player from a config entry."""
5859
server_id = config_entry.data[CONF_SERVER_IDENTIFIER]
60+
registry = await async_get_registry(hass)
5961

6062
def async_new_media_players(new_entities):
6163
_async_add_entities(
62-
hass, config_entry, async_add_entities, server_id, new_entities
64+
hass, registry, config_entry, async_add_entities, server_id, new_entities
6365
)
6466

6567
unsub = async_dispatcher_connect(
@@ -70,7 +72,7 @@ def async_new_media_players(new_entities):
7072

7173
@callback
7274
def _async_add_entities(
73-
hass, config_entry, async_add_entities, server_id, new_entities
75+
hass, registry, config_entry, async_add_entities, server_id, new_entities
7476
):
7577
"""Set up Plex media_player entities."""
7678
entities = []
@@ -79,6 +81,19 @@ def _async_add_entities(
7981
plex_mp = PlexMediaPlayer(plexserver, **entity_params)
8082
entities.append(plex_mp)
8183

84+
# Migration to per-server unique_ids
85+
old_entity_id = registry.async_get_entity_id(
86+
MP_DOMAIN, PLEX_DOMAIN, plex_mp.machine_identifier
87+
)
88+
if old_entity_id is not None:
89+
new_unique_id = f"{server_id}:{plex_mp.machine_identifier}"
90+
_LOGGER.debug(
91+
"Migrating unique_id from [%s] to [%s]",
92+
plex_mp.machine_identifier,
93+
new_unique_id,
94+
)
95+
registry.async_update_entity(old_entity_id, new_unique_id=new_unique_id)
96+
8297
async_add_entities(entities, True)
8398

8499

@@ -126,6 +141,7 @@ def __init__(self, plex_server, device, session=None):
126141
async def async_added_to_hass(self):
127142
"""Run when about to be added to hass."""
128143
server_id = self.plex_server.machine_identifier
144+
129145
unsub = async_dispatcher_connect(
130146
self.hass,
131147
PLEX_UPDATE_MEDIA_PLAYER_SIGNAL.format(self.unique_id),
@@ -315,6 +331,11 @@ def should_poll(self):
315331
@property
316332
def unique_id(self):
317333
"""Return the id of this plex client."""
334+
return f"{self.plex_server.machine_identifier}:{self._machine_identifier}"
335+
336+
@property
337+
def machine_identifier(self):
338+
"""Return the Plex-provided identifier of this plex client."""
318339
return self._machine_identifier
319340

320341
@property

homeassistant/components/plex/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ def _connect_with_url():
9494

9595
def refresh_entity(self, machine_identifier, device, session):
9696
"""Forward refresh dispatch to media_player."""
97+
unique_id = f"{self.machine_identifier}:{machine_identifier}"
9798
dispatcher_send(
9899
self._hass,
99-
PLEX_UPDATE_MEDIA_PLAYER_SIGNAL.format(machine_identifier),
100+
PLEX_UPDATE_MEDIA_PLAYER_SIGNAL.format(unique_id),
100101
device,
101102
session,
102103
)

homeassistant/components/snmp/switch.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Support for SNMP enabled switch."""
22
import logging
33

4+
from pyasn1.type.univ import Integer
5+
46
import pysnmp.hlapi.asyncio as hlapi
57
from pysnmp.hlapi.asyncio import (
68
CommunityData,
@@ -190,15 +192,20 @@ def __init__(
190192

191193
async def async_turn_on(self, **kwargs):
192194
"""Turn on the switch."""
193-
await self._set(self._command_payload_on)
195+
if self._command_payload_on.isdigit():
196+
await self._set(Integer(self._command_payload_on))
197+
else:
198+
await self._set(self._command_payload_on)
194199

195200
async def async_turn_off(self, **kwargs):
196201
"""Turn off the switch."""
197-
await self._set(self._command_payload_off)
202+
if self._command_payload_on.isdigit():
203+
await self._set(Integer(self._command_payload_off))
204+
else:
205+
await self._set(self._command_payload_off)
198206

199207
async def async_update(self):
200208
"""Update the state."""
201-
202209
errindication, errstatus, errindex, restable = await getCmd(
203210
*self._request_args, ObjectType(ObjectIdentity(self._baseoid))
204211
)
@@ -215,8 +222,12 @@ async def async_update(self):
215222
for resrow in restable:
216223
if resrow[-1] == self._payload_on:
217224
self._state = True
225+
elif resrow[-1] == Integer(self._payload_on):
226+
self._state = True
218227
elif resrow[-1] == self._payload_off:
219228
self._state = False
229+
elif resrow[-1] == Integer(self._payload_off):
230+
self._state = False
220231
else:
221232
self._state = None
222233

homeassistant/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Constants used by Home Assistant components."""
22
MAJOR_VERSION = 0
33
MINOR_VERSION = 101
4-
PATCH_VERSION = "1"
4+
PATCH_VERSION = "2"
55
__short_version__ = "{}.{}".format(MAJOR_VERSION, MINOR_VERSION)
66
__version__ = "{}.{}".format(__short_version__, PATCH_VERSION)
77
REQUIRED_PYTHON_VER = (3, 6, 1)

homeassistant/requirements.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ async def async_get_integration_with_requirements(
4848
hass, integration.domain, integration.requirements
4949
)
5050

51-
for dependency in integration.dependencies:
52-
await async_get_integration_with_requirements(hass, dependency)
51+
deps = integration.dependencies + (integration.after_dependencies or [])
52+
53+
if deps:
54+
await asyncio.gather(
55+
*[async_get_integration_with_requirements(hass, dep) for dep in deps]
56+
)
5357

5458
return integration
5559

tests/test_requirements.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,19 @@ async def test_get_integration_with_requirements(hass):
115115
mock_integration(
116116
hass, MockModule("test_component_dep", requirements=["test-comp-dep==1.0.0"])
117117
)
118+
mock_integration(
119+
hass,
120+
MockModule(
121+
"test_component_after_dep", requirements=["test-comp-after-dep==1.0.0"]
122+
),
123+
)
118124
mock_integration(
119125
hass,
120126
MockModule(
121127
"test_component",
122128
requirements=["test-comp==1.0.0"],
123129
dependencies=["test_component_dep"],
130+
partial_manifest={"after_dependencies": ["test_component_after_dep"]},
124131
),
125132
)
126133

@@ -136,13 +143,15 @@ async def test_get_integration_with_requirements(hass):
136143
assert integration
137144
assert integration.domain == "test_component"
138145

139-
assert len(mock_is_installed.mock_calls) == 2
146+
assert len(mock_is_installed.mock_calls) == 3
140147
assert mock_is_installed.mock_calls[0][1][0] == "test-comp==1.0.0"
141148
assert mock_is_installed.mock_calls[1][1][0] == "test-comp-dep==1.0.0"
149+
assert mock_is_installed.mock_calls[2][1][0] == "test-comp-after-dep==1.0.0"
142150

143-
assert len(mock_inst.mock_calls) == 2
151+
assert len(mock_inst.mock_calls) == 3
144152
assert mock_inst.mock_calls[0][1][0] == "test-comp==1.0.0"
145153
assert mock_inst.mock_calls[1][1][0] == "test-comp-dep==1.0.0"
154+
assert mock_inst.mock_calls[2][1][0] == "test-comp-after-dep==1.0.0"
146155

147156

148157
async def test_install_with_wheels_index(hass):

0 commit comments

Comments
 (0)