Summer update 😎

This commit is contained in:
ludeeus 2019-07-17 13:03:42 +00:00
parent 45617d8515
commit 8457aefc77
22 changed files with 1012 additions and 737 deletions

17
.devcontainer/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM python:3.7
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN python -m pip install --upgrade colorlog black
RUN python -m pip install --upgrade git+git://github.com/home-assistant/home-assistant.git@dev
RUN cd && mkdir -p /config/custom_components
WORKDIR /workspace
# Set the default shell to bash instead of sh
ENV SHELL /bin/bash

53
.devcontainer/README.md Normal file
View File

@ -0,0 +1,53 @@
# Devcontainer
_The easiest way to contribute to and/or test this repository._
## Requirements
- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [docker](https://docs.docker.com/install/)
- [VS Code](https://code.visualstudio.com/)
- [Remote - Containers (VSC Extention)](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
[More info about requirements and devcontainer in general](https://code.visualstudio.com/docs/remote/containers#_getting-started)
## How to use Devcontainer for development/test
1. Make sure your computer meets the requirements.
1. Fork this repository.
1. Clone the repository to your computer.
1. Open the repository using VS Code.
When you open this repository with VSCode and your computer meets the requirements you are asked to "Reopen in Container", do that.
![reopen](images/reopen.png)
If you don't see this notification, open the command pallet (ctrl+shift+p) and select `Remote-Containers: Reopen Folder in Container`.
_It will now build the devcontainer._
The container have some "tasks" to help you testing your changes.
## Custom Tasks in this repository
_Start "tasks" by opening the the command pallet (ctrl+shift+p) and select `Tasks: Run Task`_
Running tasks like `Start Home Assistant on port 8124` can be restarted by opening the the command pallet (ctrl+shift+p) and select `Tasks: Restart Running Task`, then select the task you want to restart.
### Start Home Assistant on port 8124
This will copy the configuration and the integration files to the expected location in the container.
And start up Home Assistant on [port 8124.](http://localhost:8124)
### Upgrade Home Assistant to latest dev
This will upgrade Home Assistant to the latest dev version.
### Set Home Assistant Version
This allows you to specify a version of Home Assistant to install inside the devcontainer.
### Home Assistant Config Check
This runs a config check to make sure your config is valid.

View File

@ -1,3 +1,11 @@
default_config:
logger:
default: error
logs:
custom_components.blueprint: debug
blueprint: blueprint:
username: my_username username: my_username
password: my_password password: my_password

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
function StartHomeAssistant {
echo "Copy configuration.yaml"
cp -f .devcontainer/configuration.yaml /config || echo ".devcontainer/configuration.yaml are missing!" exit 1
echo "Copy the custom component"
rm -R /config/custom_components/ || echo ""
cp -r custom_components /config/custom_components/ || echo "Could not copy the custom_component" exit 1
echo "Start Home Assistant"
hass -c /config
}
function UpdgradeHomeAssistantDev {
python -m pip install --upgrade git+git://github.com/home-assistant/home-assistant.git@dev
}
function SetHomeAssistantVersion {
read -p 'Version: ' version
python -m pip install --upgrade homeassistant==$version
}
function HomeAssistantConfigCheck {
hass -c /config --script check_config
}

View File

@ -0,0 +1,23 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"context": "..",
"dockerFile": "Dockerfile",
"appPort": "8124:8123",
"runArgs": [
"-e",
"GIT_EDTIOR='code --wait'"
],
"extensions": [
"ms-python.python"
],
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -1,9 +0,0 @@
workflow "Trigger: Push" {
on = "push"
resolves = ["Black Code Formatter"]
}
action "Black Code Formatter" {
uses = "lgeiger/black-action@master"
args = "$GITHUB_WORKSPACE --check --diff"
}

61
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,61 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Home Assistant on port 8124",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && StartHomeAssistant",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Upgrade Home Assistant to latest dev",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && UpdgradeHomeAssistantDev",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Set Home Assistant Version",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && SetHomeAssistantVersion",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Home Assistant Config Check",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && HomeAssistantConfigCheck",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
}

View File

@ -24,7 +24,6 @@ File | Purpose
-- | -- -- | --
`.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests `.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests
`.github/ISSUE_TEMPLATE/issue.md` | Template for issues `.github/ISSUE_TEMPLATE/issue.md` | Template for issues
`.github/main.workflow` | Workflow file for GitHub Actions
`.github/settings.yml` | Probot settings to control the repository settings. `.github/settings.yml` | Probot settings to control the repository settings.
`custom_components/blueprint/__init__.py` | The component file for the integration. `custom_components/blueprint/__init__.py` | The component file for the integration.
`custom_components/blueprint/binary_sensor.py` | Binary sensor platform for the integration. `custom_components/blueprint/binary_sensor.py` | Binary sensor platform for the integration.
@ -34,7 +33,7 @@ File | Purpose
`custom_components/blueprint/switch.py` | Switch sensor platform for the integration. `custom_components/blueprint/switch.py` | Switch sensor platform for the integration.
`CONTRIBUTING.md` | Guidelines on how to contribute. `CONTRIBUTING.md` | Guidelines on how to contribute.
`example.png` | Screenshot that demonstrate how it might look in the UI. `example.png` | Screenshot that demonstrate how it might look in the UI.
`example.yaml` | An example on how it might look in the users configuration.yaml file. `info.md` | An example on a info file (used by [hacs][hacs]).
`LICENSE` | The license file for the project. `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. `README.md` | The file you are reading now, should contain info about the integration, installation and configuration instructions.
@ -46,9 +45,9 @@ README content if this was a published component:
[![GitHub Release][releases-shield]][releases] [![GitHub Release][releases-shield]][releases]
[![GitHub Activity][commits-shield]][commits] [![GitHub Activity][commits-shield]][commits]
[![custom_updater][customupdaterbadge]][customupdater]
[![License][license-shield]](LICENSE.md) [![License][license-shield]](LICENSE.md)
[![hacs][hacsbadge]](hacs)
![Project Maintenance][maintenance-shield] ![Project Maintenance][maintenance-shield]
[![BuyMeCoffee][buymecoffeebadge]][buymecoffee] [![BuyMeCoffee][buymecoffeebadge]][buymecoffee]
@ -147,8 +146,8 @@ If you want to contribute to this please read the [Contribution guidelines](CONT
[buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge [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-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge
[commits]: https://github.com/custom-components/blueprint/commits/master [commits]: https://github.com/custom-components/blueprint/commits/master
[customupdater]: https://github.com/custom-components/custom_updater [hacs]: https://github.com/custom-components/hacs
[customupdaterbadge]: https://img.shields.io/badge/custom__updater-true-success.svg?style=for-the-badge [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge
[discord]: https://discord.gg/Qa5fW2R [discord]: https://discord.gg/Qa5fW2R
[discord-shield]: https://img.shields.io/discord/330944238910963714.svg?style=for-the-badge [discord-shield]: https://img.shields.io/discord/330944238910963714.svg?style=for-the-badge
[exampleimg]: example.png [exampleimg]: example.png

View File

@ -108,7 +108,6 @@ async def async_setup(hass, config):
for entry in platform_config: for entry in platform_config:
entry_config = entry entry_config = entry
_LOGGER.critical(entry_config)
# If entry is not enabled, skip. # If entry is not enabled, skip.
if not entry_config[CONF_ENABLED]: if not entry_config[CONF_ENABLED]:

98
info.md Normal file
View File

@ -0,0 +1,98 @@
[![GitHub Release][releases-shield]][releases]
[![GitHub Activity][commits-shield]][commits]
[![License][license-shield]](LICENSE.md)
[![hacs][hacsbadge]](hacs)
![Project Maintenance][maintenance-shield]
[![BuyMeCoffee][buymecoffeebadge]][buymecoffee]
[![Discord][discord-shield]][discord]
[![Community Forum][forum-shield]][forum]
_Component to integrate with [blueprint][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]
{% if not installed %}
## Installation
1. Click install.
1. Add `blueprint:` to your HA configuration.
{% endif %}
## Example configuration.yaml
```yaml
blueprint:
username: my_username
password: my_password
binary_sensor:
- enabled: true
name: My custom name
sensor:
- enabled: true
name: My custom name
switch:
- enabled: true
name: My custom name
```
## Configuration options
Key | Type | Required | Description
-- | -- | -- | --
`username` | `string` | `False` | Username for the client.
`password` | `string` | `False` | Password for the client.
`binary_sensor` | `list` | `False` | Configuration for the `binary_sensor` platform.
`sensor` | `list` | `False` | Configuration for the `sensor` platform.
`switch` | `list` | `False` | Configuration for the `switch` platform.
### Configuration options for `binary_sensor` list
Key | Type | Required | Default | Description
-- | -- | -- | -- | --
`enabled` | `boolean` | `False` | `True` | Boolean to enable/disable the platform.
`name` | `string` | `False` | `blueprint` | Custom name for the entity.
### Configuration options for `sensor` list
Key | Type | Required | Default | Description
-- | -- | -- | -- | --
`enabled` | `boolean` | `False` | `True` | Boolean to enable/disable the platform.
`name` | `string` | `False` | `blueprint` | Custom name for the entity.
### Configuration options for `switch` list
Key | Type | Required | Default | Description
-- | -- | -- | -- | --
`enabled` | `boolean` | `False` | `True` | Boolean to enable/disable the platform.
`name` | `string` | `False` | `blueprint` | Custom name for the entity.
***
[blueprint]: https://github.com/custom-components/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/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/blueprint/releases