mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-17 14:26:51 +00:00
Update code_review_platform.markdown
This commit is contained in:
parent
94306d98fb
commit
8a6ea019b4
@ -11,19 +11,14 @@ footer: true
|
|||||||
|
|
||||||
A checklist of things to do when you're adding a new platform.
|
A checklist of things to do when you're adding a new platform.
|
||||||
|
|
||||||
|
<p class='note'>
|
||||||
|
Not all existing platforms follow the requirements in this checklist. This cannot be used as a reason to not follow them!
|
||||||
|
</p>
|
||||||
|
|
||||||
### {% linkable_title 1. Requirements %}
|
### {% linkable_title 1. Requirements %}
|
||||||
|
|
||||||
1. Requirement version pinned: `REQUIREMENTS = ['phue==0.8.1']`
|
1. Requirement version should be pinned: `REQUIREMENTS = ['phue==0.8.1']`
|
||||||
2. If requirement hosted on GitHub:
|
2. We no longer want requirements hosted on GitHub. Please upload to PyPi.
|
||||||
- Point at a zip archive of a release tag or commit SHA.
|
|
||||||
- Add version found in zip-archive as hash to URL.
|
|
||||||
|
|
||||||
```python
|
|
||||||
REQUIREMENTS = [
|
|
||||||
'http://github.com/technicalpickles/python-nest'
|
|
||||||
'/archive/e6c9d56a8df455d4d7746389811f2c1387e8cb33.zip'
|
|
||||||
'#python-nest==3.0.3']
|
|
||||||
```
|
|
||||||
|
|
||||||
### {% linkable_title 2. Dependencies %}
|
### {% linkable_title 2. Dependencies %}
|
||||||
|
|
||||||
@ -65,3 +60,17 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
1. Extend entity from component, e.g. `class HueLight(Light)`
|
1. Extend entity from component, e.g. `class HueLight(Light)`
|
||||||
2. Do not call `update()` in constructor, use `add_devices(devices, True)` instead.
|
2. Do not call `update()` in constructor, use `add_devices(devices, True)` instead.
|
||||||
3. Do not do any I/O inside properties. Cache values inside `update()` instead.
|
3. Do not do any I/O inside properties. Cache values inside `update()` instead.
|
||||||
|
|
||||||
|
### {% linkable_title 6. 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.
|
||||||
|
|
||||||
|
```python
|
||||||
|
# bad
|
||||||
|
status = requests.get(url('/status'))
|
||||||
|
|
||||||
|
# good
|
||||||
|
from phue import Bridge
|
||||||
|
bridge = Bridge(…)
|
||||||
|
status = bridge.status()
|
||||||
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user