From 9b993766363a26893e7f3b9e71f63792def1bcb6 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 31 Aug 2018 09:31:37 +0200 Subject: [PATCH] Update creating_component_code_review.md --- docs/creating_component_code_review.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/creating_component_code_review.md b/docs/creating_component_code_review.md index 8040938d..5101026f 100644 --- a/docs/creating_component_code_review.md +++ b/docs/creating_component_code_review.md @@ -25,3 +25,18 @@ A checklist of things to do when you're adding a new component. 1. If you need to share global data with platforms, use the dictionary `hass.data`. `hass.data[DATA_XY]` while `XY` is the component is preferred over `hass.data[DOMAIN]`. 2. If the component fetches data that causes its related platform entities to update, you can notify them using the dispatcher code in `homeassistant.helpers.dispatcher`. + + +### 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. + +```python +# bad +status = requests.get(url('/status')) + +# good +from phue import Bridge +bridge = Bridge(…) +status = bridge.status() +```