1
mirror of https://github.com/home-assistant/core synced 2024-09-25 00:41:32 +02:00
ha-core/CONTRIBUTING.md

42 lines
2.7 KiB
Markdown
Raw Normal View History

2014-11-10 04:57:28 +01:00
# Adding support for a new device
For help on building your component, please see the See the [developer documentation on home-assistant.io](https://home-assistant.io/developers/).
2014-11-21 08:03:21 +01:00
2014-11-12 07:51:08 +01:00
After you finish adding support for your device:
2014-11-10 04:57:28 +01:00
- update the supported devices in README.md.
- add any new dependencies to requirements.txt.
2014-11-21 08:03:21 +01:00
- Make sure all your code passes Pylint, flake8 (PEP8 and some more) validation. To generate reports, run `pylint homeassistant > pylint.txt` and `flake8 homeassistant --exclude bower_components,external > flake8.txt`.
2014-11-10 04:57:28 +01:00
If you've added a component:
- update the file [`domain-icon.html`](https://github.com/balloob/home-assistant/blob/master/homeassistant/components/http/www_static/polymer/domain-icon.html) with an icon for your domain ([pick from this list](https://www.polymer-project.org/components/core-icons/demo.html))
- update the demo component with two states that it provides
- Add your component to home-assistant.conf.example
2014-11-12 07:51:08 +01:00
Since you've updated domain-icon.html, you've made changes to the frontend:
2014-11-10 04:57:28 +01:00
- run `build_frontend`. This will build a new version of the frontend. Make sure you add the changed files `frontend.py` and `frontend.html` to the commit.
## Setting states
It is the responsibility of the component to maintain the states of the devices in your domain. Each device should be a single state and, if possible, a group should be provided that tracks the combined state of the devices.
A state can have several attributes that will help the frontend in displaying your state:
- `friendly_name`: this name will be used as the name of the device
- `entity_picture`: this picture will be shown instead of the domain icon
- `unit_of_measurement`: this will be appended to the state in the interface
These attributes are defined in [homeassistant.components](https://github.com/balloob/home-assistant/blob/master/homeassistant/components/__init__.py#L25).
## Working on the frontend
2014-11-12 07:51:08 +01:00
The frontend is composed of Polymer web-components and compiled into the file `frontend.html`. During development you do not want to work with the compiled version but with the seperate files. To have Home Assistant serve the seperate files, set `development=1` for the http-component in your config.
2014-11-10 04:57:28 +01:00
2014-11-12 07:51:08 +01:00
When you are done with development and ready to commit your changes, run `build_frontend`, set `development=0` in your config and validate that everything still works.
2014-11-10 04:57:28 +01:00
## Notes on PyLint and PEP8 validation
2014-11-12 07:51:08 +01:00
In case a PyLint warning cannot be avoided, add a comment to disable the PyLint check for that line. This can be done using the format `# pylint: disable=YOUR-ERROR-NAME`. Example of an unavoidable PyLint warning is if you do not use the passed in datetime if you're listening for time change.