Skip to content

Add WLED integration#28542

Merged
frenck merged 26 commits into
devfrom
frenck-2019-0257
Nov 6, 2019
Merged

Add WLED integration#28542
frenck merged 26 commits into
devfrom
frenck-2019-0257

Conversation

@frenck
Copy link
Copy Markdown
Member

@frenck frenck commented Nov 4, 2019

Description:

Add initial integration for WLED.

https://github.com/Aircoookie/WLED/

WLED is a firmware for ESP8266/ESP32 that allows users to turn such a chip into a LED controller easy, while extremely feature-rich as well.

The current implementation supports auto-discovery, the light (led strip).

While the WLED firmware is far more feature right, this PR aims to be an initial step up.

ℹ️ My aim for this integration is to hit the platinum quality scale. If you think it doesn't hit that, please let me know. (see: Checklist)

2019-11-05 00 53 54

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#11103

Example entry for configuration.yaml (if applicable): Config flow only.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@frenck
Copy link
Copy Markdown
Member Author

frenck commented Nov 5, 2019

Integration Quality Scale

The Integration Quality Scale scores each integration based on the code quality and user experience. Each level of the quality scale consists of a list of requirements. If an integration matches all requirements, it's considered to have reached that level.

Silver 🥈

This integration is able to cope when things go wrong. It will not print any exceptions nor will it fill the log with retry attempts.

  • Connection/configuration is handled via a component.

  • Set an appropriate SCAN_INTERVAL (if a polling integration)

  • Raise PlatformNotReady if unable to connect during platform setup (if appropriate)

    Throws ConfigEntryNotReady on a integration level. Uses data loaded during the integration setup to set up the platforms.

  • Handles expiration of auth credentials. Refresh if possible or print correct error and fail setup. If based on a config entry, should trigger a new config entry flow to re-authorize.

    Does not apply to WLED.

  • Handles internet unavailable. Log a warning once when unavailable, log once when reconnected.
    Handles device/service unavailable. Log a warning once when unavailable, log once when reconnected.

  • Set available property to False if appropriate

  • Entities have unique ID (if available)

Gold 🥇

This is a solid integration that is able to survive poor conditions and can be configured via the user interface.

  • Configurable via config entries.
    • Don't allow configuring already configured device/service
    • Tests for the config flow
    • Discoverable (if available)
  • Entities have device info (if available)
  • States are translated in the frontend (text-based sensors only)

    No states are in need of translation

  • Tests for reading data from/controlling the integration
  • Has a code owner

Platinum 🏆

Best of the best. The integration is completely async, meaning it's super fast. Integrations that reach platinum level will require approval by the code owner for each PR.

  • Set appropriate PARALLEL_UPDATES constant
  • Support config entry unloading (called when config entry is removed)
  • Integration + dependency are async
  • Uses aiohttp and allows passing in websession (if making HTTP requests)

@MartinHjelmare
Copy link
Copy Markdown
Member

Please start with the light platform in this PR and move the other platforms to follow up PRs that can come after this is merged. It won't affect the quality scale and we can merge faster.

@frenck
Copy link
Copy Markdown
Member Author

frenck commented Nov 5, 2019

@MartinHjelmare Done 👍

Edit: commit message is misleading, it removed the "sensor & switch" platform. Oops
Since we squash and merge, I'll just leave it for now.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

I haven't looked at the tests yet.

Comment thread homeassistant/components/wled/strings.json Outdated
Comment thread homeassistant/components/wled/__init__.py Outdated
Comment thread homeassistant/components/wled/__init__.py Outdated
Comment thread homeassistant/components/wled/__init__.py Outdated
Comment thread homeassistant/components/wled/__init__.py Outdated
Comment thread homeassistant/components/wled/config_flow.py Outdated
Comment thread homeassistant/components/wled/light.py Outdated
Comment thread homeassistant/components/wled/light.py Outdated
Comment thread homeassistant/components/wled/light.py Outdated
Comment thread homeassistant/components/wled/light.py Outdated
@frenck
Copy link
Copy Markdown
Member Author

frenck commented Nov 5, 2019

@MartinHjelmare Done. Processed all review comments.

@frenck frenck requested a review from MartinHjelmare November 5, 2019 20:34
Comment thread homeassistant/components/wled/config_flow.py
Comment thread tests/fixtures/wled.json Outdated
Comment thread homeassistant/components/wled/config_flow.py Outdated
Comment thread homeassistant/components/wled/config_flow.py Outdated
Comment thread homeassistant/components/wled/light.py
Comment thread homeassistant/components/wled/manifest.json Outdated
Comment thread homeassistant/components/wled/__init__.py
Comment thread homeassistant/components/wled/config_flow.py
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

We want to use the core interfaces when setting up the tests and patch in the perifery, to make the tests more robust.

Comment thread tests/components/wled/__init__.py Outdated
Comment thread tests/components/wled/test_init.py Outdated
Comment thread tests/components/wled/test_init.py Outdated
Comment thread tests/components/wled/test_init.py Outdated
Comment thread tests/components/wled/test_init.py Outdated
Comment thread tests/components/wled/test_light.py Outdated
@frenck frenck requested a review from MartinHjelmare November 6, 2019 20:09
@frenck
Copy link
Copy Markdown
Member Author

frenck commented Nov 6, 2019

Done, I'm ready for the next round 😉

No really, thanks, guys! It helps a lot (and I learned a lot again) 👍

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks great!

@frenck frenck merged commit 78b83c6 into dev Nov 6, 2019
@delete-merged-branch delete-merged-branch Bot deleted the frenck-2019-0257 branch November 6, 2019 22:55
@lock lock Bot locked and limited conversation to collaborators Nov 7, 2019
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.

5 participants