Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022.2.2 #65713

Merged
merged 22 commits into from
Feb 4, 2022
Merged

2022.2.2 #65713

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a670317
Bumped boschshcpy 0.2.28 to 0.2.29 (#65328)
tschamm Feb 4, 2022
3babc43
Add migration to migrate 'homewizard_energy' to 'homewizard' (#65594)
DCSBL Feb 4, 2022
9eeaec4
Raise when zwave_js device automation fails validation (#65610)
raman325 Feb 4, 2022
06b6b17
Bump androidtv to 0.0.62 (#65440)
JeffLIrion Feb 3, 2022
b004c5d
Bump androidtv to 0.0.63 (fix MAC issues) (#65615)
JeffLIrion Feb 4, 2022
c6d5a08
Bump homematicip to 1.0.2 (#65620)
balloob Feb 4, 2022
0efa276
Bump flux_led to 0.28.20 (#65621)
bdraco Feb 4, 2022
67a9932
Fix Z-Wave lights (#65638)
alexanv1 Feb 4, 2022
4e3cd14
Remove limit of amount of duplicated statistics (#65641)
emontnemery Feb 4, 2022
9cd6bb7
Don't use shared session during recorder migration (#65672)
emontnemery Feb 4, 2022
ea1245f
Improve recorder migration for PostgreSQL when columns already exist …
emontnemery Feb 4, 2022
e6e95a1
Only remove duplicated statistics on error (#65653)
emontnemery Feb 4, 2022
35f2536
Bump renault-api to 0.1.8 (#65670)
epenet Feb 4, 2022
84b2ec2
Fix warm/cold reversal in rgbww_to_color_temperature (#65677)
bdraco Feb 4, 2022
5aa02b8
Call out 3rd party containers more clearly (#65684)
balloob Feb 4, 2022
6cf2665
Fix "vevent" KeyError in caldav component again (#65685)
jkuettner Feb 4, 2022
27dbf98
Allow selecting own repositories (#65695)
ludeeus Feb 4, 2022
609661a
Move scene and button restore to internal hook (#65696)
balloob Feb 4, 2022
5a44f8e
Fix passing a string to device registry disabled_by (#65701)
balloob Feb 4, 2022
56d1fc6
Fix tuya diagnostics mutating cached state objects (#65708)
balloob Feb 4, 2022
1a2e9aa
Depend on diagnostics in the frontend (#65710)
frenck Feb 4, 2022
51abdf9
Bumped version to 2022.2.2
balloob Feb 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions homeassistant/components/androidtv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ async def _async_check_connection(self, user_input):
return RESULT_CONN_ERROR, None

dev_prop = aftv.device_properties
_LOGGER.info(
"Android TV at %s: %s = %r, %s = %r",
user_input[CONF_HOST],
PROP_ETHMAC,
dev_prop.get(PROP_ETHMAC),
PROP_WIFIMAC,
dev_prop.get(PROP_WIFIMAC),
)
unique_id = format_mac(
dev_prop.get(PROP_ETHMAC) or dev_prop.get(PROP_WIFIMAC, "")
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/androidtv/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"documentation": "https://www.home-assistant.io/integrations/androidtv",
"requirements": [
"adb-shell[async]==0.4.0",
"androidtv[async]==0.0.61",
"androidtv[async]==0.0.63",
"pure-python-adb[async]==0.3.0.dev0"
],
"codeowners": ["@JeffLIrion", "@ollo69"],
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bosch_shc/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Bosch SHC",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/bosch_shc",
"requirements": ["boschshcpy==0.2.28"],
"requirements": ["boschshcpy==0.2.29"],
"zeroconf": [{ "type": "_http._tcp.local.", "name": "bosch shc*" }],
"iot_class": "local_push",
"codeowners": ["@tschamm"],
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/button/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ async def _async_press_action(self) -> None:
self.async_write_ha_state()
await self.async_press()

async def async_added_to_hass(self) -> None:
async def async_internal_added_to_hass(self) -> None:
"""Call when the button is added to hass."""
await super().async_internal_added_to_hass()
state = await self.async_get_last_state()
if state is not None and state.state is not None:
self.__last_pressed = dt_util.parse_datetime(state.state)
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/caldav/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ def update(self):
new_events.append(new_event)
elif _start_of_tomorrow <= start_dt:
break
vevents = [event.instance.vevent for event in results + new_events]
vevents = [
event.instance.vevent
for event in results + new_events
if hasattr(event.instance, "vevent")
]

# dtstart can be a date or datetime depending if the event lasts a
# whole day. Convert everything to datetime to be able to sort it
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/config/device_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ async def websocket_update_device(hass, connection, msg):
msg.pop("type")
msg_id = msg.pop("id")

if "disabled_by" in msg:
msg["disabled_by"] = DeviceEntryDisabler(msg["disabled_by"])

entry = registry.async_update_device(**msg)

connection.send_message(websocket_api.result_message(msg_id, _entry_dict(entry)))
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/default_config/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"cloud",
"counter",
"dhcp",
"diagnostics",
"energy",
"frontend",
"history",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/flux_led/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"dependencies": ["network"],
"documentation": "https://www.home-assistant.io/integrations/flux_led",
"requirements": ["flux_led==0.28.17"],
"requirements": ["flux_led==0.28.20"],
"quality_scale": "platinum",
"codeowners": ["@icemanch", "@bdraco"],
"iot_class": "local_push",
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/frontend/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth",
"config",
"device_automation",
"diagnostics",
"http",
"lovelace",
"onboarding",
Expand Down
50 changes: 38 additions & 12 deletions homeassistant/components/github/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
GitHubException,
GitHubLoginDeviceModel,
GitHubLoginOauthModel,
GitHubRepositoryModel,
)
from aiogithubapi.const import OAUTH_USER_LOGIN
import voluptuous as vol
Expand All @@ -34,11 +33,12 @@
)


async def starred_repositories(hass: HomeAssistant, access_token: str) -> list[str]:
"""Return a list of repositories that the user has starred."""
async def get_repositories(hass: HomeAssistant, access_token: str) -> list[str]:
"""Return a list of repositories that the user owns or has starred."""
client = GitHubAPI(token=access_token, session=async_get_clientsession(hass))
repositories = set()

async def _get_starred() -> list[GitHubRepositoryModel] | None:
async def _get_starred_repositories() -> None:
response = await client.user.starred(**{"params": {"per_page": 100}})
if not response.is_last_page:
results = await asyncio.gather(
Expand All @@ -54,16 +54,44 @@ async def _get_starred() -> list[GitHubRepositoryModel] | None:
for result in results:
response.data.extend(result.data)

return response.data
repositories.update(response.data)

async def _get_personal_repositories() -> None:
response = await client.user.repos(**{"params": {"per_page": 100}})
if not response.is_last_page:
results = await asyncio.gather(
*(
client.user.repos(
**{"params": {"per_page": 100, "page": page_number}},
)
for page_number in range(
response.next_page_number, response.last_page_number + 1
)
)
)
for result in results:
response.data.extend(result.data)

repositories.update(response.data)

try:
result = await _get_starred()
await asyncio.gather(
*(
_get_starred_repositories(),
_get_personal_repositories(),
)
)

except GitHubException:
return DEFAULT_REPOSITORIES

if not result or len(result) == 0:
if len(repositories) == 0:
return DEFAULT_REPOSITORIES
return sorted((repo.full_name for repo in result), key=str.casefold)

return sorted(
(repo.full_name for repo in repositories),
key=str.casefold,
)


class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Expand Down Expand Up @@ -153,9 +181,7 @@ async def async_step_repositories(
assert self._login is not None

if not user_input:
repositories = await starred_repositories(
self.hass, self._login.access_token
)
repositories = await get_repositories(self.hass, self._login.access_token)
return self.async_show_form(
step_id="repositories",
data_schema=vol.Schema(
Expand Down Expand Up @@ -205,7 +231,7 @@ async def async_step_init(
configured_repositories: list[str] = self.config_entry.options[
CONF_REPOSITORIES
]
repositories = await starred_repositories(
repositories = await get_repositories(
self.hass, self.config_entry.data[CONF_ACCESS_TOKEN]
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/github/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "GitHub",
"documentation": "https://www.home-assistant.io/integrations/github",
"requirements": [
"aiogithubapi==22.1.0"
"aiogithubapi==22.2.0"
],
"codeowners": [
"@timmo001",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homematicip_cloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "HomematicIP Cloud",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/homematicip_cloud",
"requirements": ["homematicip==1.0.1"],
"requirements": ["homematicip==1.0.2"],
"codeowners": [],
"quality_scale": "platinum",
"iot_class": "cloud_push"
Expand Down
48 changes: 47 additions & 1 deletion homeassistant/components/homewizard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

from aiohwenergy import DisabledError

from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_IP_ADDRESS
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.update_coordinator import UpdateFailed

from .const import DOMAIN, PLATFORMS
Expand All @@ -20,6 +21,51 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

_LOGGER.debug("__init__ async_setup_entry")

# Migrate `homewizard_energy` (custom_component) to `homewizard`
if entry.source == SOURCE_IMPORT and "old_config_entry_id" in entry.data:
# Remove the old config entry ID from the entry data so we don't try this again
# on the next setup
data = entry.data.copy()
old_config_entry_id = data.pop("old_config_entry_id")

hass.config_entries.async_update_entry(entry, data=data)
_LOGGER.debug(
(
"Setting up imported homewizard_energy entry %s for the first time as "
"homewizard entry %s"
),
old_config_entry_id,
entry.entry_id,
)

ent_reg = er.async_get(hass)
for entity in er.async_entries_for_config_entry(ent_reg, old_config_entry_id):
_LOGGER.debug("Removing %s", entity.entity_id)
ent_reg.async_remove(entity.entity_id)

_LOGGER.debug("Re-creating %s for the new config entry", entity.entity_id)
# We will precreate the entity so that any customizations can be preserved
new_entity = ent_reg.async_get_or_create(
entity.domain,
DOMAIN,
entity.unique_id,
suggested_object_id=entity.entity_id.split(".")[1],
disabled_by=entity.disabled_by,
config_entry=entry,
original_name=entity.original_name,
original_icon=entity.original_icon,
)
_LOGGER.debug("Re-created %s", new_entity.entity_id)

# If there are customizations on the old entity, apply them to the new one
if entity.name or entity.icon:
ent_reg.async_update_entity(
new_entity.entity_id, name=entity.name, icon=entity.icon
)

# Remove the old config entry and now the entry is fully migrated
hass.async_create_task(hass.config_entries.async_remove(old_config_entry_id))

# Create coordinator
coordinator = Coordinator(hass, entry.data[CONF_IP_ADDRESS])
try:
Expand Down
26 changes: 23 additions & 3 deletions homeassistant/components/homewizard/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ def __init__(self) -> None:
"""Initialize the HomeWizard config flow."""
self.config: dict[str, str | int] = {}

async def async_step_import(self, import_config: dict) -> FlowResult:
"""Handle a flow initiated by older `homewizard_energy` component."""
_LOGGER.debug("config_flow async_step_import")

self.hass.components.persistent_notification.async_create(
(
"The custom integration of HomeWizard Energy has been migrated to core. "
"You can safely remove the custom integration from the custom_integrations folder."
),
"HomeWizard Energy",
f"homewizard_energy_to_{DOMAIN}",
)

return await self.async_step_user({CONF_IP_ADDRESS: import_config["host"]})

async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
Expand Down Expand Up @@ -59,12 +74,17 @@ async def async_step_user(
}
)

data: dict[str, str] = {CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS]}

if self.source == config_entries.SOURCE_IMPORT:
old_config_entry_id = self.context["old_config_entry_id"]
assert self.hass.config_entries.async_get_entry(old_config_entry_id)
data["old_config_entry_id"] = old_config_entry_id

# Add entry
return self.async_create_entry(
title=f"{device_info[CONF_PRODUCT_NAME]} ({device_info[CONF_SERIAL]})",
data={
CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS],
},
data=data,
)

async def async_step_zeroconf(
Expand Down