1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-12-06 18:44:14 -05:00

📝 Add docstrings to mqtt

Docstrings generation was requested by @natekspencer.

* https://github.com/natekspencer/hacs-oasis_mini/pull/98#issuecomment-3568450288

The following files were modified:

* `custom_components/oasis_mini/__init__.py`
* `custom_components/oasis_mini/binary_sensor.py`
* `custom_components/oasis_mini/button.py`
* `custom_components/oasis_mini/config_flow.py`
* `custom_components/oasis_mini/coordinator.py`
* `custom_components/oasis_mini/entity.py`
* `custom_components/oasis_mini/helpers.py`
* `custom_components/oasis_mini/image.py`
* `custom_components/oasis_mini/light.py`
* `custom_components/oasis_mini/media_player.py`
* `custom_components/oasis_mini/number.py`
* `custom_components/oasis_mini/pyoasiscontrol/clients/cloud_client.py`
* `custom_components/oasis_mini/pyoasiscontrol/clients/http_client.py`
* `custom_components/oasis_mini/pyoasiscontrol/clients/mqtt_client.py`
* `custom_components/oasis_mini/pyoasiscontrol/clients/transport.py`
* `custom_components/oasis_mini/pyoasiscontrol/device.py`
* `custom_components/oasis_mini/pyoasiscontrol/utils.py`
* `custom_components/oasis_mini/select.py`
* `custom_components/oasis_mini/sensor.py`
* `custom_components/oasis_mini/switch.py`
* `custom_components/oasis_mini/update.py`
* `update_tracks.py`
This commit is contained in:
coderabbitai[bot]
2025-11-23 23:18:59 +00:00
committed by GitHub
parent cf21a5d995
commit 4ef28fc741
22 changed files with 1635 additions and 164 deletions

View File

@@ -28,9 +28,24 @@ async def async_setup_entry(
entry: OasisDeviceConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Oasis device button using config entry."""
"""
Create and add button entities for each Oasis device defined in the config entry.
Parameters:
entry (OasisDeviceConfigEntry): Config entry containing runtime data and registered Oasis devices.
async_add_entities (AddEntitiesCallback): Callback used to register the created entities with Home Assistant.
"""
def make_entities(new_devices: list[OasisDevice]):
"""
Create button entities for each provided Oasis device using the module descriptors.
Parameters:
new_devices (list[OasisDevice]): Devices to create button entities for.
Returns:
list[OasisDeviceButtonEntity]: Button entity instances created for each device and each descriptor in DESCRIPTORS.
"""
return [
OasisDeviceButtonEntity(entry.runtime_data, device, descriptor)
for device in new_devices
@@ -41,7 +56,17 @@ async def async_setup_entry(
async def play_random_track(device: OasisDevice) -> None:
"""Play random track."""
"""
Play a random track on the given Oasis device.
Selects a track at random from the available TRACKS and attempts to add it to the device's queue and play it. Raises HomeAssistantError if adding the track times out.
Parameters:
device: The Oasis device on which to play the track.
Raises:
HomeAssistantError: If adding the selected track to the device's queue times out.
"""
track = random.choice(list(TRACKS))
try:
await add_and_play_track(device, track)
@@ -82,5 +107,9 @@ class OasisDeviceButtonEntity(OasisDeviceEntity, ButtonEntity):
entity_description: OasisDeviceButtonEntityDescription
async def async_press(self) -> None:
"""Press the button."""
await self.entity_description.press_fn(self.device)
"""
Trigger the button's configured action on the associated device.
Calls the entity description's `press_fn` with the device to perform the button's effect.
"""
await self.entity_description.press_fn(self.device)