mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Minor typos and clarity edits (#1136)
This commit is contained in:
parent
6dbc73be12
commit
82661b43a7
@ -9,24 +9,24 @@ sharing: true
|
|||||||
footer: true
|
footer: true
|
||||||
---
|
---
|
||||||
|
|
||||||
Components that interact with devices are called "[Entity Components](https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/entity_component.py)". They are structured in core- and platform logic. This allows the same logic to handle a light to be used by different brands.
|
Components that interact with devices are called "[Entity Components](https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/entity_component.py)." They are structured in core and platform logic, which means different brands can use the same logic to handle a light.
|
||||||
|
|
||||||
For example, the built-in `switch` component consists of various platforms in [`homeassistant/components/switch/`](https://github.com/home-assistant/home-assistant/tree/master/homeassistant/components/switch). The file `__init__.py` contains the core logic of all platform and the `vendor_name.py` files only the relevant platform code.
|
For example, the built-in `switch` component consists of various platforms in [`homeassistant/components/switch/`](https://github.com/home-assistant/home-assistant/tree/master/homeassistant/components/switch). The file `__init__.py` contains the core logic of all platforms and the `vendor_name.py` files contain only the relevant platform code.
|
||||||
|
|
||||||
If you are planning to add support for a new type of device to an existing component, you can get away with only writing platform logic. Have a look at how the component works with other platforms and create a similar file for the platform that you would like to add:
|
If you're planning to add support for a new type of device to an existing component, you can get away with only writing platform logic. Have a look at how the component works with other platforms and create a similar file for the platform that you want to add:
|
||||||
|
|
||||||
- [Example sensor platform](/developers/platform_example_sensor): hello world of platforms.
|
- [Example sensor platform](/developers/platform_example_sensor): hello world of platforms.
|
||||||
- [Example light platform](/developers/platform_example_light): showing best practices.
|
- [Example light platform](/developers/platform_example_light): showing best practices.
|
||||||
|
|
||||||
### {% linkable_title Interfacing with devices %}
|
### {% linkable_title Interfacing with devices %}
|
||||||
|
|
||||||
One of the rules for Home Assistant is that platform logic should never interface directly with devices but use a third-party Python 3 library to do so. This way Home Assistant is able to share code with the Python community and we can keep the project maintainable.
|
One Home Assistant rule is that platform logic should never interface directly with devices. Instead, use a third-party Python 3 library. This way, Home Assistant can share code with the Python community and keep the project maintainable.
|
||||||
|
|
||||||
To integrate the third-party library you create an [Entity class](https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/entity.py) for your device. Entities are Home Assistant's representation of lights, switches, sensors, etc. and are derived from the [Entity Abstract Class](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/helpers/entity.py). This abstract class contains logic for integrating most standard features into your entities, such as visibility, entity IDs, updates, and much more.
|
To integrate the third-party library, create an [Entity class](https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/entity.py) for your device. Entities are Home Assistant's representations of lights, switches, sensors, etc. and are derived from the [Entity Abstract Class](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/helpers/entity.py). This abstract class contains logic for integrating most standard features into your entities, such as visibility, entity IDs, updates, and much more.
|
||||||
|
|
||||||
### {% linkable_title Requirements and dependencies %}
|
### {% linkable_title Requirements and dependencies %}
|
||||||
|
|
||||||
Platforms can specify dependencies and requirements [the same way as a component does](/developers/component_deps_and_reqs):
|
Platforms can specify dependencies and requirements [the same way as components](/developers/component_deps_and_reqs):
|
||||||
|
|
||||||
```python
|
```python
|
||||||
REQUIREMENTS = ['some-package==2.0.0', 'some-other-package==2.5.0']
|
REQUIREMENTS = ['some-package==2.0.0', 'some-other-package==2.5.0']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user