Update code review requirements (#268)

This commit is contained in:
Paulus Schoutsen 2019-06-01 18:23:58 -07:00 committed by Alexei Chetroi
parent 9241c0f2af
commit 1724776c39
2 changed files with 5 additions and 11 deletions

View File

@ -5,7 +5,7 @@ sidebar_label: Component Checklist
A checklist of things to do when you're adding a new component. A checklist of things to do when you're adding a new component.
> Not all existing platforms follow the requirements in this checklist. This cannot be used as a reason to not follow them! > Not all existing code follow the requirements in this checklist. This cannot be used as a reason to not follow them!
### 0. Common ### 0. Common
@ -18,7 +18,6 @@ A checklist of things to do when you're adding a new component.
1. Requirements have been added to [`manifest.json`](creating_integration_manifest.md). The `REQUIREMENTS` constant is deprecated. 1. Requirements have been added to [`manifest.json`](creating_integration_manifest.md). The `REQUIREMENTS` constant is deprecated.
2. Requirement version should be pinned: `"requirements": ['phue==0.8.1']` 2. Requirement version should be pinned: `"requirements": ['phue==0.8.1']`
3. We no longer want requirements hosted on GitHub. Please upload to PyPi. 3. We no longer want requirements hosted on GitHub. Please upload to PyPi.
4. Requirements should only be imported inside functions. This is necessary because requirements are installed on the fly.
### 2. Configuration ### 2. Configuration

View File

@ -19,15 +19,10 @@ A checklist of things to do when you're adding a new platform.
1. Requirements have been added to [`manifest.json`](creating_integration_manifest.md). The `REQUIREMENTS` constant is deprecated. 1. Requirements have been added to [`manifest.json`](creating_integration_manifest.md). The `REQUIREMENTS` constant is deprecated.
2. Requirement version should be pinned: `"requirements": ['phue==0.8.1']` 2. Requirement version should be pinned: `"requirements": ['phue==0.8.1']`
3. We no longer want requirements hosted on GitHub. Please upload to PyPi. 3. We no longer want requirements hosted on GitHub. Please upload to PyPi.
4. Requirements should only be imported inside functions. This is necessary because requirements are installed on the fly.
### 2. Dependencies ### 2. Configuration
1. If you depend on a component for the connection, add it to your dependencies in [`manifest.json`](creating_integration_manifest.md): `"dependencies": ['nest']`. The `DEPENDENCIES` constant is deprecated. 1. If the platform can be set up directly, add a voluptuous schema for [configuration validation](development_validation.md)
### 3. Configuration
1. Voluptuous schema present for [configuration validation](development_validation.md)
2. Voluptuous schema extends schema from component<br>(e.g., `hue.light.PLATFORM_SCHEMA` extends `light.PLATFORM_SCHEMA`) 2. Voluptuous schema extends schema from component<br>(e.g., `hue.light.PLATFORM_SCHEMA` extends `light.PLATFORM_SCHEMA`)
3. Default parameters specified in voluptuous schema, not in `setup_platform(...)` 3. Default parameters specified in voluptuous schema, not in `setup_platform(...)`
4. Your `PLATFORM_SCHEMA` should use as many generic config keys as possible from `homeassistant.const` 4. Your `PLATFORM_SCHEMA` should use as many generic config keys as possible from `homeassistant.const`
@ -51,7 +46,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
}) })
``` ```
### 4. Setup Platform ### 3. Setup Platform
1. Verify that the passed in configuration (user/pass/host etc.) works. 1. Verify that the passed in configuration (user/pass/host etc.) works.
2. Group your calls to `add_devices` if possible. 2. Group your calls to `add_devices` if possible.
@ -74,7 +69,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
5. When dealing with time, state and/or attributes should not contain relative time since something happened. Instead, it should store UTC timestamps. 5. When dealing with time, state and/or attributes should not contain relative time since something happened. Instead, it should store UTC timestamps.
6. Leverage the [entity lifecycle callbacks](entity_index.md#lifecycle-hooks) to attach event listeners or clean up connections. 6. Leverage the [entity lifecycle callbacks](entity_index.md#lifecycle-hooks) to attach event listeners or clean up connections.
### 6. Communication with devices/services ### 4. Communication with devices/services
1. All API specific code has to be part of a third party library hosted on PyPi. Home Assistant should only interact with objects and not make direct calls to the API. 1. All API specific code has to be part of a third party library hosted on PyPi. Home Assistant should only interact with objects and not make direct calls to the API.