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
@@ -27,9 +27,22 @@ async def async_setup_entry(
|
||||
entry: OasisDeviceConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Oasis device numbers using config entry."""
|
||||
"""
|
||||
Set up number entities for Oasis devices from a configuration entry.
|
||||
|
||||
Creates number entities for each discovered Oasis device and each descriptor in DESCRIPTORS, then registers those entities with the platform coordinator so they are added to Home Assistant.
|
||||
"""
|
||||
|
||||
def make_entities(new_devices: list[OasisDevice]):
|
||||
"""
|
||||
Create number entity instances for each provided Oasis device using the module's DESCRIPTORS.
|
||||
|
||||
Parameters:
|
||||
new_devices (list[OasisDevice]): Devices to create entities for.
|
||||
|
||||
Returns:
|
||||
list[OasisDeviceNumberEntity]: A flat list of number entities (one per descriptor for each device).
|
||||
"""
|
||||
return [
|
||||
OasisDeviceNumberEntity(entry.runtime_data, device, descriptor)
|
||||
for device in new_devices
|
||||
@@ -64,13 +77,25 @@ class OasisDeviceNumberEntity(OasisDeviceEntity, NumberEntity):
|
||||
|
||||
@property
|
||||
def native_value(self) -> str | None:
|
||||
"""Return the value reported by the number."""
|
||||
"""
|
||||
Get the current value of the number entity from the underlying device.
|
||||
|
||||
Returns:
|
||||
str | None: The current value as a string, or `None` if the device has no value.
|
||||
"""
|
||||
return getattr(self.device, self.entity_description.key)
|
||||
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set new value."""
|
||||
"""
|
||||
Set the configured numeric value on the underlying Oasis device.
|
||||
|
||||
The provided value is converted to an integer and applied to the device property indicated by this entity's description key: if the key is "ball_speed" the device's ball speed is updated; if the key is "led_speed" the device's LED speed is updated.
|
||||
|
||||
Parameters:
|
||||
value (float): New numeric value to apply; will be converted to an integer.
|
||||
"""
|
||||
value = int(value)
|
||||
if self.entity_description.key == "ball_speed":
|
||||
await self.device.async_set_ball_speed(value)
|
||||
elif self.entity_description.key == "led_speed":
|
||||
await self.device.async_set_led(led_speed=value)
|
||||
await self.device.async_set_led(led_speed=value)
|
||||
Reference in New Issue
Block a user