Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LetPot integration #134925

Merged
merged 7 commits into from
Jan 8, 2025
Merged

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Jan 6, 2025

Breaking change

Proposed change

Add a new integration for LetPot hydroponic gardens/systems. You can control the light (and in the future more, and view state info like whether the pump is running or if there are any issues).

As the initial platform you might expect light, but the device actually doesn't let you toggle the light directly but only via the light schedule (when should the light turn on or turn off). As a result I've chosen time as the platform for this PR.

Dialog titled 'LetPot', with inputs for Email (The email address of your LetPot account.) and Password (The password of your LetPot account.) > Dialog titled 'Success!' showing 1 device discovered.

Config entry showing 'Hubs', with the user's email address as the title and 1 device, 2 entities

Device page showing some basic device info (model name, model ID, manufacturer, serial number) and two entities: Light off (18:00 set) and Light on (8:00 set)

Bronze

  • config-flow - Integration needs to be able to be set up via the UI - see config_flow.py and manifest.json L5
    • Uses data_description to give context to fields - see strings.json L9-L12
    • Uses ConfigEntry.data and ConfigEntry.options correctly - all stored data is used for authentication so in ConfigEntry.data
  • test-before-configure - Test a connection in the config flow - see config_flow.py L74
  • unique-config-entry - Don't allow the same device or service to be able to be set up twice - see config_flow.py L85-L86
  • config-flow-test-coverage - Full test coverage for the config flow - see:
    pytest output showing 100% coverage for config_flow.py
  • runtime-data - Use ConfigEntry.runtime_data to store runtime data - see __init__.py L86
  • test-before-setup - Check during integration initialization if we are able to set it up correctly - see __init__.py L60, L65, L67
  • [E] appropriate-polling - If it's a polling integration, set an appropriate polling interval - exempt: this integration only receives push-based updates
  • entity-unique-id - Entities have a unique ID - see time.py L82
  • has-entity-name - Entities use has_entity_name = True - see entity.py L13
  • entity-event-setup - Entities event setup - see entity.py L10: using CoordinatorEntity as base with push updates, no other events
  • dependency-transparency - Dependency transparency - see library https://github.com/jpelgrom/python-letpot: MIT licensed, published to PyPI using CI action triggered by GitHub releases
  • [E] action-setup - Service actions are registered in async_setup - exempt: this integration does not provide additional actions
  • common-modules - Place common patterns in common modules - see file names
  • docs-high-level-description - The documentation includes a high-level description of the integration brand, product, or service - see docs PR
  • docs-installation-instructions - The documentation provides step-by-step installation instructions for the integration, including, if needed, prerequisites - see docs PR
  • docs-removal-instructions - The documentation provides removal instructions - see docs PR
  • [E] docs-actions - The documentation describes the provided service actions that can be used - exempt: this integration does not provide additional actions
  • brands - Has branding assets available for the integration - see brands PR

Silver

  • config-entry-unloading - Support config entry unloading - push connection connects in coordinator.py _async_setup, disconnects in __init__.py async_unload_entry
  • log-when-unavailable - If internet/device/service is unavailable, log once when unavailable and once when back connected
  • entity-unavailable - Mark entity unavailable if appropriate
  • action-exceptions - Service actions raise exceptions when encountering failures
  • reauthentication-flow - Reauthentication flow
  • parallel-updates - Set Parallel updates - see time.py L22
  • test-coverage - Above 95% test coverage for all integration modules
  • integration-owner - Has an integration owner - see updated CODEOWNERS and manifest.json L4
  • docs-installation-parameters - The documentation describes all integration installation parameters - see docs PR
  • [E] docs-configuration-parameters - The documentation describes all integration configuration options - exempt: the integration does not have configuration options

Gold

  • entity-translations - Entities have translated names - see time.py L36, L45
  • entity-device-class - Entities use device classes where possible
  • devices - The integration creates devices - see entity.py L18-L25
  • entity-category - Entities are assigned an appropriate EntityCategory
  • entity-disabled-by-default - Integration disables less popular (or noisy) entities
  • discovery - Can be discovered
  • stale-devices - Clean up stale devices
  • diagnostics - Implements diagnostics
  • exception-translations - Exception messages are translatable
  • icon-translations - Icon translations
  • reconfiguration-flow - Integrations should have a reconfigure flow
  • dynamic-devices - Devices added after integration setup
  • discovery-update-info - Integration uses discovery info to update network information
  • repair-issues - Repair issues and repair flows are used when user intervention is needed
  • docs-use-cases - The documentation describes use cases to illustrate how this integration can be used
  • docs-supported-devices - The documentation describes known supported / unsupported devices - see docs PR
  • docs-supported-functions - The documentation describes the supported functionality, including entities, and platforms
  • docs-data-update - The documentation describes how data is updated - see docs PR
  • docs-known-limitations - The documentation describes known limitations of the integration (not to be confused with bugs)
  • docs-troubleshooting - The documentation provides troubleshooting information
  • docs-examples - The documentation provides automation examples the user can use.

Platinum

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

homeassistant/components/letpot/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/letpot/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/letpot/coordinator.py Outdated Show resolved Hide resolved
homeassistant/components/letpot/coordinator.py Outdated Show resolved Hide resolved
homeassistant/components/letpot/time.py Outdated Show resolved Hide resolved
"""Initialize LetPot time entity."""
super().__init__(coordinator)
self.entity_description = description
self._attr_unique_id = f"{coordinator.config_entry.unique_id}_{coordinator.device.serial_number}_{description.key}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the entry unique id as well? Can multiple accounts share a device?

Copy link
Member Author

@jpelgrom jpelgrom Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually yes as of yesterday :)

I coded this before yesterday though and believe it is required to make sure you don't get conflicts in case you have >1 device? If your account is abcd and you have two devices which both will have a sensor with description light_schedule_start, wouldn't you end up with the unique id abcd_light_schedule_start twice?

Edit: misread that, yes entry unique ID wouldn't have been required if one device is only for one account, but now that there is device sharing between accounts it is.

@jpelgrom jpelgrom marked this pull request as ready for review January 8, 2025 19:27
@jpelgrom
Copy link
Member Author

jpelgrom commented Jan 8, 2025

Not sure what the failing job codecov/patch — 51.36% of diff hit (target 81.16%) really means or how to fix it.

homeassistant/components/letpot/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/letpot/coordinator.py Outdated Show resolved Hide resolved
tests/components/letpot/test_config_flow.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft January 8, 2025 19:43
@home-assistant
Copy link

home-assistant bot commented Jan 8, 2025

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@jpelgrom jpelgrom marked this pull request as ready for review January 8, 2025 20:04
@home-assistant home-assistant bot requested a review from joostlek January 8, 2025 20:04
@joostlek joostlek merged commit 4129697 into home-assistant:dev Jan 8, 2025
61 checks passed
@jpelgrom jpelgrom deleted the letpot-integration branch January 8, 2025 20:40
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants