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:
committed by
GitHub
parent
cf21a5d995
commit
4ef28fc741
@@ -19,9 +19,27 @@ async def async_setup_entry(
|
||||
entry: OasisDeviceConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Oasis device switchs using config entry."""
|
||||
"""
|
||||
Set up Oasis device switch entities for a config entry.
|
||||
|
||||
Creates an OasisDeviceSwitchEntity for each OasisDevice associated with the given config entry (one entity per descriptor in DESCRIPTORS) and registers them with Home Assistant via the coordinator helper.
|
||||
|
||||
Parameters:
|
||||
hass: Home Assistant core instance.
|
||||
entry: OasisDeviceConfigEntry containing runtime data and the devices to expose as switch entities.
|
||||
async_add_entities: Callback used to register created entities with Home Assistant.
|
||||
"""
|
||||
|
||||
def make_entities(new_devices: list[OasisDevice]):
|
||||
"""
|
||||
Create OasisDeviceSwitchEntity instances for each device and descriptor.
|
||||
|
||||
Parameters:
|
||||
new_devices (list[OasisDevice]): Devices to wrap as switch entities.
|
||||
|
||||
Returns:
|
||||
list[OasisDeviceSwitchEntity]: A list containing one switch entity per device per descriptor from DESCRIPTORS.
|
||||
"""
|
||||
return [
|
||||
OasisDeviceSwitchEntity(entry.runtime_data, device, descriptor)
|
||||
for device in new_devices
|
||||
@@ -45,13 +63,24 @@ class OasisDeviceSwitchEntity(OasisDeviceEntity, SwitchEntity):
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return True if entity is on."""
|
||||
"""
|
||||
Determine whether the switch entity is currently on.
|
||||
|
||||
Returns:
|
||||
bool: `True` if the underlying device attribute named by this entity's description key is truthy, `False` otherwise.
|
||||
"""
|
||||
return bool(getattr(self.device, self.entity_description.key))
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
"""
|
||||
Disable the device's automatic cleaning mode.
|
||||
|
||||
Sets the device's auto_clean setting to off.
|
||||
"""
|
||||
await self.device.async_set_auto_clean(False)
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity on."""
|
||||
await self.device.async_set_auto_clean(True)
|
||||
"""
|
||||
Enable the device's auto-clean feature.
|
||||
"""
|
||||
await self.device.async_set_auto_clean(True)
|
||||
Reference in New Issue
Block a user