fix action Action commit Created package file minor updates Add binary_sensor Updated package file Updated package file Fix BinarySensor Class name Add more descriptions Updated package file Move stuff Updated package file add binary_sensor to resources.json Updated package file Add configuration Updated package file Remove switch Adds CONTRIBUTING Fix broken link Remove refrences Fix links fix broken actions Update actions Updated package file Updated package file Black format Fix config issues Updated package file Fix icon for binary_sensor Add switch platform Update README.md (#1) * Update README.md * Update README.md Update CONTRIBUTING.md (#2) Update __init__.py (#3) * Update __init__.py * Set enabled default to `True` Update const.py (#4) cleanup badges/add style (#5) * shield that supports styling * badge cleanup * Change discord ID Correct typo Create manifest.json (#12) Fixes https://github.com/custom-components/blueprint/issues/10 Move manifest to correct dir Fixes #9 by renaming the file Updates, updates, more updates, worst commit messge ever! revert Update main.workflow Delete resources.json Create example.yaml Update README.md Summer update 😎 Adds info about devcontainer Adds pylint Add translation example remove stalebot Adds integrationhelper adds requirements.txt Adds "tabnine.tabnine-vscode" to devcontainer Add support for config_flow configuration Add config_flow "docs" Update README.md use https for pip install ha@dev (#15) Typo on README.md (#18) Fix various typos in comments (#19) Add hassfest action (#22) * Add hassfest action * Fix manifest issue Spring cleaning ☀️ (#23) * Spring cleaning * Actions * Fix branches * Changes for config_flow Show how to only allow one instance Adds HACS validation action (#24) Update postCreateCommand Update tasks Minor updates (#26) * link correction in README.md and info.md * Add READMME.md for .devcontainer * Add automation.yaml file in the configuration * Complete CONTRIBUTING.md Improve README for container dev and library update. (#27) Feature/setup cfg (#28) * Add setup.cfg * Run black and isort. * Add blueprint to first party. * Make const import consistent. Move translation files Fixes #32 Use CoordinatorEntity (#33) Co-authored-by: Joakim Sørensen <hi@ludeeus.dev> Fixed typos (#34) Fix directory name for translations and link to the documentation (#36) Fix info.md (#40) Use debian based devcontainer (#44) Remove sampleclient (#45) Rename [blueprint|Blueprint] -> [integration_blueprint|Integration blueprint] (#47) Change HACS action (#39) Fix wrong path for link (#48) For an unknown reason the link was pointing to a one of my repository. Probably a too quick copy/paste. Add french translation and strings improvements (#49) Reusing work done on strings.json done in #37 Add example tests (#50) Prepare and explain how to step by step debugging (#51) Add version Fix testing by bumping pytest-homeassistant-custom-component (#54) Fix typo in api.py (#55) passeword -> password Fix a typo in the readme (#56) Update .gitignore to include .idea (#57) Update .gitignore to include .idea for those using Py Charm Add iot_class to manifest Use `enable_custom_integrations` fixture by default (#58) Fix typo (#59) retain user input after an error (#52) Update README.md Closes #61 remove async_timeout.timeout loop arg (#65) Correct name "Blueprint" ->"Integration blueprint" (#64) change entity.py to use extra_state_attributes (#66)
152 lines
8.2 KiB
Markdown
152 lines
8.2 KiB
Markdown
# Notice
|
|
|
|
The component and platforms in this repository are not meant to be used by a
|
|
user, but as a "blueprint" that custom component developers can build
|
|
upon, to make more awesome stuff.
|
|
|
|
HAVE FUN! 😎
|
|
|
|
## Why?
|
|
|
|
This is simple, by having custom_components look (README + structure) the same
|
|
it is easier for developers to help each other and for users to start using them.
|
|
|
|
If you are a developer and you want to add things to this "blueprint" that you think more
|
|
developers will have use for, please open a PR to add it :)
|
|
|
|
## What?
|
|
|
|
This repository contains multiple files, here is a overview:
|
|
|
|
File | Purpose
|
|
-- | --
|
|
`.devcontainer/*` | Used for development/testing with VSCODE, more info in the readme file in that dir.
|
|
`.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests
|
|
`.github/ISSUE_TEMPLATE/issue.md` | Template for issues
|
|
`.vscode/tasks.json` | Tasks for the devcontainer.
|
|
`custom_components/integration_blueprint/translations/*` | [Translation files.](https://developers.home-assistant.io/docs/internationalization/custom_integration)
|
|
`custom_components/integration_blueprint/__init__.py` | The component file for the integration.
|
|
`custom_components/integration_blueprint/api.py` | This is a sample API client.
|
|
`custom_components/integration_blueprint/binary_sensor.py` | Binary sensor platform for the integration.
|
|
`custom_components/integration_blueprint/config_flow.py` | Config flow file, this adds the UI configuration possibilities.
|
|
`custom_components/integration_blueprint/const.py` | A file to hold shared variables/constants for the entire integration.
|
|
`custom_components/integration_blueprint/manifest.json` | A [manifest file](https://developers.home-assistant.io/docs/en/creating_integration_manifest.html) for Home Assistant.
|
|
`custom_components/integration_blueprint/sensor.py` | Sensor platform for the integration.
|
|
`custom_components/integration_blueprint/switch.py` | Switch sensor platform for the integration.
|
|
`tests/__init__.py` | Makes the `tests` folder a module.
|
|
`tests/conftest.py` | Global [fixtures](https://docs.pytest.org/en/stable/fixture.html) used in tests to [patch](https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch) functions.
|
|
`tests/test_api.py` | Tests for `custom_components/integration_blueprint/api.py`.
|
|
`tests/test_config_flow.py` | Tests for `custom_components/integration_blueprint/config_flow.py`.
|
|
`tests/test_init.py` | Tests for `custom_components/integration_blueprint/__init__.py`.
|
|
`tests/test_switch.py` | Tests for `custom_components/integration_blueprint/switch.py`.
|
|
`CONTRIBUTING.md` | Guidelines on how to contribute.
|
|
`example.png` | Screenshot that demonstrate how it might look in the UI.
|
|
`info.md` | An example on a info file (used by [hacs][hacs]).
|
|
`LICENSE` | The license file for the project.
|
|
`README.md` | The file you are reading now, should contain info about the integration, installation and configuration instructions.
|
|
`requirements.txt` | Python packages used by this integration.
|
|
`requirements_dev.txt` | Python packages used to provide [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense)/code hints during development of this integration, typically includes packages in `requirements.txt` but may include additional packages
|
|
`requirements_test.txt` | Python packages required to run the tests for this integration, typically includes packages in `requirements_dev.txt` but may include additional packages
|
|
|
|
## How?
|
|
|
|
If you want to use all the potential and features of this blueprint template you
|
|
should use Visual Studio Code to develop in a container. In this container you
|
|
will have all the tools to ease your python development and a dedicated Home
|
|
Assistant core instance to run your integration. See `.devcontainer/README.md` for more information.
|
|
|
|
If you need to work on the python library in parallel of this integration
|
|
(`sampleclient` in this example) there are different options. The following one seems
|
|
easy to implement:
|
|
|
|
- Create a dedicated branch for your python library on a public git repository (example: branch
|
|
`dev` on `https://github.com/ludeeus/sampleclient`)
|
|
- Update in the `manifest.json` file the `requirements` key to point on your development branch
|
|
( example: `"requirements": ["git+https://github.com/ludeeus/sampleclient.git@dev#devp==0.0.1beta1"]`)
|
|
- Each time you need to make a modification to your python library, push it to your
|
|
development branch and increase the number of the python library version in `manifest.json` file
|
|
to ensure Home Assistant update the code of the python library. (example `"requirements": ["git+https://...==0.0.1beta2"]`).
|
|
|
|
|
|
***
|
|
README content if this was a published component:
|
|
***
|
|
|
|
# integration_blueprint
|
|
|
|
[![GitHub Release][releases-shield]][releases]
|
|
[![GitHub Activity][commits-shield]][commits]
|
|
[![License][license-shield]](LICENSE)
|
|
|
|
[![hacs][hacsbadge]][hacs]
|
|
![Project Maintenance][maintenance-shield]
|
|
[![BuyMeCoffee][buymecoffeebadge]][buymecoffee]
|
|
|
|
[![Discord][discord-shield]][discord]
|
|
[![Community Forum][forum-shield]][forum]
|
|
|
|
_Component to integrate with [integration_blueprint][integration_blueprint]._
|
|
|
|
**This component will set up the following platforms.**
|
|
|
|
Platform | Description
|
|
-- | --
|
|
`binary_sensor` | Show something `True` or `False`.
|
|
`sensor` | Show info from blueprint API.
|
|
`switch` | Switch something `True` or `False`.
|
|
|
|
![example][exampleimg]
|
|
|
|
## Installation
|
|
|
|
1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
|
|
2. If you do not have a `custom_components` directory (folder) there, you need to create it.
|
|
3. In the `custom_components` directory (folder) create a new folder called `integration_blueprint`.
|
|
4. Download _all_ the files from the `custom_components/integration_blueprint/` directory (folder) in this repository.
|
|
5. Place the files you downloaded in the new directory (folder) you created.
|
|
6. Restart Home Assistant
|
|
7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Integration blueprint"
|
|
|
|
Using your HA configuration directory (folder) as a starting point you should now also have this:
|
|
|
|
```text
|
|
custom_components/integration_blueprint/translations/en.json
|
|
custom_components/integration_blueprint/translations/nb.json
|
|
custom_components/integration_blueprint/translations/sensor.nb.json
|
|
custom_components/integration_blueprint/__init__.py
|
|
custom_components/integration_blueprint/api.py
|
|
custom_components/integration_blueprint/binary_sensor.py
|
|
custom_components/integration_blueprint/config_flow.py
|
|
custom_components/integration_blueprint/const.py
|
|
custom_components/integration_blueprint/manifest.json
|
|
custom_components/integration_blueprint/sensor.py
|
|
custom_components/integration_blueprint/switch.py
|
|
```
|
|
|
|
## Configuration is done in the UI
|
|
|
|
<!---->
|
|
|
|
## Contributions are welcome!
|
|
|
|
If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md)
|
|
|
|
***
|
|
|
|
[integration_blueprint]: https://github.com/custom-components/integration_blueprint
|
|
[buymecoffee]: https://www.buymeacoffee.com/ludeeus
|
|
[buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge
|
|
[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge
|
|
[commits]: https://github.com/custom-components/integration_blueprint/commits/master
|
|
[hacs]: https://github.com/custom-components/hacs
|
|
[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge
|
|
[discord]: https://discord.gg/Qa5fW2R
|
|
[discord-shield]: https://img.shields.io/discord/330944238910963714.svg?style=for-the-badge
|
|
[exampleimg]: example.png
|
|
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge
|
|
[forum]: https://community.home-assistant.io/
|
|
[license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge
|
|
[maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge
|
|
[releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge
|
|
[releases]: https://github.com/custom-components/integration_blueprint/releases
|