Skip to content
Merged
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
59 changes: 29 additions & 30 deletions homeassistant/components/homematicip_cloud/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

from typing import Any

from homematicip.base.enums import DeviceType
from homematicip.base.enums import DeviceType, FunctionalChannelType
from homematicip.device import (
BrandSwitch2,
DinRailSwitch,
DinRailSwitch4,
FullFlushInputSwitch,
HeatingSwitch2,
MotionDetectorSwitchOutdoor,
MultiIOBox,
OpenCollector8Module,
PlugableSwitch,
Expand Down Expand Up @@ -47,45 +48,43 @@ async def async_setup_entry(
and getattr(device, "deviceType", None) != DeviceType.BRAND_SWITCH_MEASURING
):
entities.append(HomematicipSwitchMeasuring(hap, device))
elif isinstance(device, WiredSwitch8):
entities.extend(
HomematicipMultiSwitch(hap, device, channel=channel)
for channel in range(1, 9)
)
elif isinstance(device, DinRailSwitch):
entities.append(HomematicipMultiSwitch(hap, device, channel=1))
elif isinstance(device, DinRailSwitch4):
entities.extend(
HomematicipMultiSwitch(hap, device, channel=channel)
for channel in range(1, 5)
)
elif isinstance(
device,
(
PlugableSwitch,
PrintedCircuitBoardSwitchBattery,
FullFlushInputSwitch,
WiredSwitch8,
OpenCollector8Module,
BrandSwitch2,
PrintedCircuitBoardSwitch2,
HeatingSwitch2,
MultiIOBox,
MotionDetectorSwitchOutdoor,
DinRailSwitch,
DinRailSwitch4,
),
):
entities.append(HomematicipSwitch(hap, device))
elif isinstance(device, OpenCollector8Module):
channel_indices = [
ch.index
for ch in device.functionalChannels
if ch.functionalChannelType
in (
FunctionalChannelType.SWITCH_CHANNEL,
FunctionalChannelType.MULTI_MODE_INPUT_SWITCH_CHANNEL,
)
]
entities.extend(
HomematicipMultiSwitch(hap, device, channel=channel)
for channel in range(1, 9)
for channel in channel_indices
)

elif isinstance(
device,
(
BrandSwitch2,
PrintedCircuitBoardSwitch2,
HeatingSwitch2,
MultiIOBox,
PlugableSwitch,
PrintedCircuitBoardSwitchBattery,
FullFlushInputSwitch,
),
):
entities.extend(
HomematicipMultiSwitch(hap, device, channel=channel)
for channel in range(1, 3)
)
entities.append(HomematicipSwitch(hap, device))

async_add_entities(entities)

Expand All @@ -108,15 +107,15 @@ def __init__(
@property
def is_on(self) -> bool:
"""Return true if switch is on."""
return self._device.functionalChannels[self._channel].on
return self.functional_channel.on

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the switch on."""
await self._device.turn_on_async(self._channel)
await self.functional_channel.async_turn_on()

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the switch off."""
await self._device.turn_off_async(self._channel)
await self.functional_channel.async_turn_off()


class HomematicipSwitch(HomematicipMultiSwitch, SwitchEntity):
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/motion_blinds/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
BlindType.VerticalBlind: CoverDeviceClass.BLIND,
BlindType.VerticalBlindLeft: CoverDeviceClass.BLIND,
BlindType.VerticalBlindRight: CoverDeviceClass.BLIND,
BlindType.RollerTiltMotor: CoverDeviceClass.BLIND,
}

TILT_ONLY_DEVICE_MAP = {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/motion_blinds/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"documentation": "https://www.home-assistant.io/integrations/motion_blinds",
"iot_class": "local_push",
"loggers": ["motionblinds"],
"requirements": ["motionblinds==0.6.27"]
"requirements": ["motionblinds==0.6.28"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/roku/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"integration_type": "device",
"iot_class": "local_polling",
"loggers": ["rokuecp"],
"requirements": ["rokuecp==0.19.3"],
"requirements": ["rokuecp==0.19.5"],
"ssdp": [
{
"st": "roku:ecp",
Expand Down
8 changes: 6 additions & 2 deletions homeassistant/components/shelly/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ def __init__(
self._attr_unique_id = f"{coordinator.mac}_{description.key}"
if isinstance(coordinator, ShellyBlockCoordinator):
self._attr_device_info = get_block_device_info(
coordinator.device, coordinator.mac
coordinator.device,
coordinator.mac,
suggested_area=coordinator.suggested_area,
)
else:
self._attr_device_info = get_rpc_device_info(
coordinator.device, coordinator.mac
coordinator.device,
coordinator.mac,
suggested_area=coordinator.suggested_area,
)
self._attr_device_info = DeviceInfo(
connections={(CONNECTION_NETWORK_MAC, coordinator.mac)}
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/shelly/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ def __init__(
elif entry is not None:
self._unique_id = entry.unique_id
self._attr_device_info = get_block_device_info(
coordinator.device, coordinator.mac, sensor_block
coordinator.device,
coordinator.mac,
sensor_block,
suggested_area=coordinator.suggested_area,
)
self._attr_name = get_block_entity_name(
self.coordinator.device, sensor_block, None
Expand Down
12 changes: 11 additions & 1 deletion homeassistant/components/shelly/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
Platform,
)
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
from homeassistant.helpers import device_registry as dr, issue_registry as ir
from homeassistant.helpers import (
area_registry as ar,
device_registry as dr,
issue_registry as ir,
)
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, format_mac
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
Expand Down Expand Up @@ -114,6 +118,7 @@ def __init__(
self.device = device
self.device_id: str | None = None
self._pending_platforms: list[Platform] | None = None
self.suggested_area: str | None = None
device_name = device.name if device.initialized else entry.title
interval_td = timedelta(seconds=update_interval)
# The device has come online at least once. In the case of a sleeping RPC
Expand Down Expand Up @@ -176,6 +181,11 @@ def async_setup(self, pending_platforms: list[Platform] | None = None) -> None:
hw_version=f"gen{get_device_entry_gen(self.config_entry)}",
configuration_url=f"http://{get_host(self.config_entry.data[CONF_HOST])}:{get_http_port(self.config_entry.data)}",
)
# We want to use the main device area as the suggested area for sub-devices.
if (area_id := device_entry.area_id) is not None:
area_registry = ar.async_get(self.hass)
if (area := area_registry.async_get_area(area_id)) is not None:
self.suggested_area = area.name
self.device_id = device_entry.id

async def shutdown(self) -> None:
Expand Down
24 changes: 19 additions & 5 deletions homeassistant/components/shelly/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ def __init__(self, coordinator: ShellyBlockCoordinator, block: Block) -> None:
self.block = block
self._attr_name = get_block_entity_name(coordinator.device, block)
self._attr_device_info = get_block_device_info(
coordinator.device, coordinator.mac, block
coordinator.device,
coordinator.mac,
block,
suggested_area=coordinator.suggested_area,
)
self._attr_unique_id = f"{coordinator.mac}-{block.description}"

Expand Down Expand Up @@ -405,7 +408,10 @@ def __init__(self, coordinator: ShellyRpcCoordinator, key: str) -> None:
super().__init__(coordinator)
self.key = key
self._attr_device_info = get_rpc_device_info(
coordinator.device, coordinator.mac, key
coordinator.device,
coordinator.mac,
key,
suggested_area=coordinator.suggested_area,
)
self._attr_unique_id = f"{coordinator.mac}-{key}"
self._attr_name = get_rpc_entity_name(coordinator.device, key)
Expand Down Expand Up @@ -521,7 +527,9 @@ def __init__(
)
self._attr_unique_id = f"{coordinator.mac}-{attribute}"
self._attr_device_info = get_block_device_info(
coordinator.device, coordinator.mac
coordinator.device,
coordinator.mac,
suggested_area=coordinator.suggested_area,
)
self._last_value = None

Expand Down Expand Up @@ -630,7 +638,10 @@ def __init__(
self.entity_description = description

self._attr_device_info = get_block_device_info(
coordinator.device, coordinator.mac, block
coordinator.device,
coordinator.mac,
block,
suggested_area=coordinator.suggested_area,
)

if block is not None:
Expand Down Expand Up @@ -698,7 +709,10 @@ def __init__(
self.entity_description = description

self._attr_device_info = get_rpc_device_info(
coordinator.device, coordinator.mac, key
coordinator.device,
coordinator.mac,
key,
suggested_area=coordinator.suggested_area,
)
self._attr_unique_id = self._attr_unique_id = (
f"{coordinator.mac}-{key}-{attribute}"
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/shelly/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ def __init__(
super().__init__(coordinator)
self.event_id = int(key.split(":")[-1])
self._attr_device_info = get_rpc_device_info(
coordinator.device, coordinator.mac, key
coordinator.device,
coordinator.mac,
key,
suggested_area=coordinator.suggested_area,
)
self._attr_unique_id = f"{coordinator.mac}-{key}"
self._attr_name = get_rpc_entity_name(coordinator.device, key)
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/shelly/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ def __init__(
super().__init__(coordinator, key, attribute, description)

self._attr_device_info = get_rpc_device_info(
coordinator.device, coordinator.mac, key, description.emeter_phase
coordinator.device,
coordinator.mac,
key,
emeter_phase=description.emeter_phase,
suggested_area=coordinator.suggested_area,
)


Expand Down
9 changes: 8 additions & 1 deletion homeassistant/components/shelly/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ def get_rpc_device_info(
mac: str,
key: str | None = None,
emeter_phase: str | None = None,
suggested_area: str | None = None,
) -> DeviceInfo:
"""Return device info for RPC device."""
if key is None:
Expand All @@ -770,6 +771,7 @@ def get_rpc_device_info(
identifiers={(DOMAIN, f"{mac}-{key}-{emeter_phase.lower()}")},
name=get_rpc_sub_device_name(device, key, emeter_phase),
manufacturer="Shelly",
suggested_area=suggested_area,
via_device=(DOMAIN, mac),
)

Expand All @@ -784,6 +786,7 @@ def get_rpc_device_info(
identifiers={(DOMAIN, f"{mac}-{key}")},
name=get_rpc_sub_device_name(device, key),
manufacturer="Shelly",
suggested_area=suggested_area,
via_device=(DOMAIN, mac),
)

Expand All @@ -805,7 +808,10 @@ def get_blu_trv_device_info(


def get_block_device_info(
device: BlockDevice, mac: str, block: Block | None = None
device: BlockDevice,
mac: str,
block: Block | None = None,
suggested_area: str | None = None,
) -> DeviceInfo:
"""Return device info for Block device."""
if (
Expand All @@ -820,6 +826,7 @@ def get_block_device_info(
identifiers={(DOMAIN, f"{mac}-{block.description}")},
name=get_block_sub_device_name(device, block),
manufacturer="Shelly",
suggested_area=suggested_area,
via_device=(DOMAIN, mac),
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ aiofiles==24.1.0
aiohasupervisor==0.3.1
aiohttp-asyncmdnsresolver==0.1.1
aiohttp-fast-zlib==0.3.0
aiohttp==3.12.12
aiohttp==3.12.13
aiohttp_cors==0.8.1
aiousbwatcher==1.1.1
aiozoneinfo==0.2.3
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
# change behavior based on presence of supervisor. Deprecated with #127228
# Lib can be removed with 2025.11
"aiohasupervisor==0.3.1",
"aiohttp==3.12.12",
"aiohttp==3.12.13",
"aiohttp_cors==0.8.1",
"aiohttp-fast-zlib==0.3.0",
"aiohttp-asyncmdnsresolver==0.1.1",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading