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
@@ -21,9 +21,27 @@ async def async_setup_entry(
|
||||
entry: OasisDeviceConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Oasis device sensors using config entry."""
|
||||
"""
|
||||
Set up and register sensor entities for each Oasis device in the config entry.
|
||||
|
||||
Creates sensor entities for every Oasis device available on the provided config entry and adds them to Home Assistant via the provided add-entities callback.
|
||||
|
||||
Parameters:
|
||||
hass (HomeAssistant): Home Assistant core object.
|
||||
entry (OasisDeviceConfigEntry): Configuration entry containing runtime data and devices to expose.
|
||||
async_add_entities (AddEntitiesCallback): Callback to add created entities to Home Assistant.
|
||||
"""
|
||||
|
||||
def make_entities(new_devices: list[OasisDevice]):
|
||||
"""
|
||||
Create sensor entity instances for each Oasis device and each sensor descriptor.
|
||||
|
||||
Parameters:
|
||||
new_devices (list[OasisDevice]): Devices to create sensor entities for.
|
||||
|
||||
Returns:
|
||||
list[OasisDeviceSensorEntity]: A list containing one sensor entity per combination of device and descriptor from DESCRIPTORS.
|
||||
"""
|
||||
return [
|
||||
OasisDeviceSensorEntity(entry.runtime_data, device, descriptor)
|
||||
for device in new_devices
|
||||
@@ -67,5 +85,10 @@ class OasisDeviceSensorEntity(OasisDeviceEntity, SensorEntity):
|
||||
|
||||
@property
|
||||
def native_value(self) -> str | None:
|
||||
"""Return the value reported by the sensor."""
|
||||
return getattr(self.device, self.entity_description.key)
|
||||
"""
|
||||
Provide the current sensor value from the underlying device.
|
||||
|
||||
Returns:
|
||||
`str` with the sensor's current value, or `None` if the attribute is not present or has no value. The value is taken from the device attribute named by the entity description's `key`.
|
||||
"""
|
||||
return getattr(self.device, self.entity_description.key)
|
||||
Reference in New Issue
Block a user