init
This commit is contained in:
commit
f686660196
17
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
37
.github/ISSUE_TEMPLATE/issue.md
vendored
Normal file
37
.github/ISSUE_TEMPLATE/issue.md
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
name: Issue
|
||||||
|
about: Create a report to help us improve
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Before you open a new issue, search through the existing issues to see if others have had the same problem.
|
||||||
|
|
||||||
|
Issues not containing the minimum requirements will be closed:
|
||||||
|
|
||||||
|
- Issues without a description (using the header is not good enough) will be closed.
|
||||||
|
- Issues without debug logging will be closed.
|
||||||
|
- Issues without configuration will be closed
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
## Version of the custom_component
|
||||||
|
<!-- If you are not using the newest version, download and try that before opening an issue-->
|
||||||
|
|
||||||
|
## Describe the bug
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
## `custom_updater` configuration
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
|
||||||
|
# Add configuration here
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Debug log
|
||||||
|
|
||||||
|
```text
|
||||||
|
|
||||||
|
Add your logs here.
|
||||||
|
|
||||||
|
```
|
38
.github/main.workflow
vendored
Normal file
38
.github/main.workflow
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
workflow "Trigger: Push to master from admin account" {
|
||||||
|
on = "push"
|
||||||
|
resolves = [
|
||||||
|
"HA Index"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow "Trigger: Push" {
|
||||||
|
on = "push"
|
||||||
|
resolves = [
|
||||||
|
"Black Code Formatter"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action "branch-filter" {
|
||||||
|
uses = "actions/bin/filter@master"
|
||||||
|
args = "branch master"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "Access control" {
|
||||||
|
uses = "ludeeus/actions/accesscontrol@master"
|
||||||
|
env = {
|
||||||
|
ACTION_LEVEL = "admin"
|
||||||
|
}
|
||||||
|
secrets = ["GITHUB_TOKEN"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "HA Index" {
|
||||||
|
uses = "ludeeus/actions/haindex@master"
|
||||||
|
secrets = ["GITHUB_TOKEN"]
|
||||||
|
needs = ["branch-filter", "Access control"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "Black Code Formatter" {
|
||||||
|
uses = "lgeiger/black-action@v1.0.1"
|
||||||
|
args = "$GITHUB_WORKSPACE --check"
|
||||||
|
}
|
23
.github/settings.yml
vendored
Normal file
23
.github/settings.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
repository:
|
||||||
|
private: false
|
||||||
|
has_issues: true
|
||||||
|
has_projects: false
|
||||||
|
has_wiki: false
|
||||||
|
has_downloads: false
|
||||||
|
default_branch: master
|
||||||
|
allow_squash_merge: true
|
||||||
|
allow_merge_commit: false
|
||||||
|
allow_rebase_merge: false
|
||||||
|
labels:
|
||||||
|
- name: "Feature Request"
|
||||||
|
color: "fbca04"
|
||||||
|
- name: "Bug"
|
||||||
|
color: "b60205"
|
||||||
|
- name: "Wont Fix"
|
||||||
|
color: "ffffff"
|
||||||
|
- name: "Enhancement"
|
||||||
|
color: a2eeef
|
||||||
|
- name: "Documentation"
|
||||||
|
color: "008672"
|
||||||
|
- name: "Stale"
|
||||||
|
color: "930191"
|
16
.github/stale.yml
vendored
Normal file
16
.github/stale.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Number of days of inactivity before an issue becomes stale
|
||||||
|
daysUntilStale: 14
|
||||||
|
# Number of days of inactivity before a stale issue is closed
|
||||||
|
daysUntilClose: 7
|
||||||
|
# Issues with these labels will never be considered stale
|
||||||
|
#exemptLabels:
|
||||||
|
# - pinned
|
||||||
|
# - security
|
||||||
|
# Label to use when marking an issue as stale
|
||||||
|
staleLabel: Stale
|
||||||
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
|
markComment: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed if no further activity occurs.
|
||||||
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||||
|
closeComment: false
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Joakim Sørensen @ludeeus
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
47
README.md
Normal file
47
README.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# blueprint
|
||||||
|
|
||||||
|
[![BuyMeCoffee][buymecoffeebedge]][buymecoffee]
|
||||||
|
[![custom_updater][customupdaterbadge]][customupdater]
|
||||||
|
|
||||||
|
_Component to integrate with [blueprint][blueprint]._
|
||||||
|
|
||||||
|
**This component will set up the following platforms.**
|
||||||
|
|
||||||
|
Platform | Description
|
||||||
|
-- | --
|
||||||
|
`sensor` | Show info from blueprint API.
|
||||||
|
|
||||||
|
![example][exampleimg]
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. Using you 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 `blueprint`.
|
||||||
|
4. Download _all_ the files from the `custom_components/blueprint/` directory (folder) in this repository.
|
||||||
|
5. Place the files you downloaded in the new directory (folder) you created.
|
||||||
|
6. Add `blueprint:` to your HA configuration.
|
||||||
|
|
||||||
|
Using your HA configuration directory (folder) as a starting point you should now also have this:
|
||||||
|
|
||||||
|
```text
|
||||||
|
custom_components/blueprint/__init__.py
|
||||||
|
custom_components/blueprint/const.py
|
||||||
|
custom_components/blueprint/sensor.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example configuration.yaml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
blueprint:
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
[exampleimg]: example.png
|
||||||
|
[buymecoffee]: https://www.buymeacoffee.com/ludeeus
|
||||||
|
[buymecoffeebedge]: https://camo.githubusercontent.com/cd005dca0ef55d7725912ec03a936d3a7c8de5b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275792532306d6525323061253230636f666665652d646f6e6174652d79656c6c6f772e737667
|
||||||
|
[blueprint]: https://github.com/custom-components/blueprint
|
||||||
|
[customupdater]: https://github.com/custom-components/custom_updater
|
||||||
|
[customupdaterbadge]: https://img.shields.io/badge/custom__updater-true-success.svg
|
66
custom_components/blueprint/__init__.py
Normal file
66
custom_components/blueprint/__init__.py
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
"""
|
||||||
|
Component to integrate with https://blueprint.com/api
|
||||||
|
|
||||||
|
For more details about this component, please refer to
|
||||||
|
https://github.com/custom-components/blueprint
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import requests
|
||||||
|
from homeassistant.helpers import discovery
|
||||||
|
|
||||||
|
from .const import * # pylint: disable=wildcard-import
|
||||||
|
|
||||||
|
VERSION = '0.0.1'
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
|
||||||
|
async def async_setup(hass, config):
|
||||||
|
"""Set up this component."""
|
||||||
|
|
||||||
|
# Print startup message
|
||||||
|
startup = STARTUP.format(name=DOMAIN, version=VERSION, issueurl=ISSUE_URL)
|
||||||
|
_LOGGER.info(startup)
|
||||||
|
|
||||||
|
# Check that all required files are present
|
||||||
|
file_check = await check_files(hass)
|
||||||
|
if not file_check:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Create DATA dict
|
||||||
|
hass.data[DOMAIN_DATA] = {}
|
||||||
|
|
||||||
|
# Load platforms
|
||||||
|
for platform in PLATFORMS:
|
||||||
|
hass.async_create_task(
|
||||||
|
discovery.async_load_platform(hass, platform, DOMAIN, {}, config))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def update_data(hass):
|
||||||
|
"""Update data."""
|
||||||
|
try:
|
||||||
|
request = requests.get(URL)
|
||||||
|
jsondata = request.json()
|
||||||
|
hass.data[DOMAIN_DATA] = jsondata
|
||||||
|
except Exception as error: # pylint: disable=broad-except
|
||||||
|
_LOGGER.error("Could not update data - %s", error)
|
||||||
|
|
||||||
|
|
||||||
|
async def check_files(hass):
|
||||||
|
"""Retrun bool that idicate that all files are present."""
|
||||||
|
base = "{}/custom_components/{}/".format(hass.config.path(), DOMAIN)
|
||||||
|
missing = []
|
||||||
|
for file in REQUIRED_FILES:
|
||||||
|
fullpath = "{}{}".format(base, file)
|
||||||
|
if not os.path.exists(fullpath):
|
||||||
|
missing.append(file)
|
||||||
|
|
||||||
|
if missing:
|
||||||
|
_LOGGER.critical("The following files are missing: %s", str(missing))
|
||||||
|
returnvalue = False
|
||||||
|
else:
|
||||||
|
returnvalue = True
|
||||||
|
|
||||||
|
return returnvalue
|
18
custom_components/blueprint/const.py
Normal file
18
custom_components/blueprint/const.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
"""Consts"""
|
||||||
|
DOMAIN = 'blueprint'
|
||||||
|
DOMAIN_DATA = '{}_data'.format(DOMAIN)
|
||||||
|
VERSION = '0.0.1'
|
||||||
|
URL = 'https://blueprint.com/api'
|
||||||
|
REQUIRED_FILES = ['sensor.py', 'const.py']
|
||||||
|
ISSUE_URL = 'https://github.com/custom-components/blueprint/issues'
|
||||||
|
PLATFORMS = ['sensor']
|
||||||
|
|
||||||
|
STARTUP = """
|
||||||
|
----------------------------------------------
|
||||||
|
{name}
|
||||||
|
Version: {version}
|
||||||
|
This is a custom component
|
||||||
|
If you have any issues with this you need to open an issue here:
|
||||||
|
{issueurl}
|
||||||
|
----------------------------------------------
|
||||||
|
"""
|
42
custom_components/blueprint/sensor.py
Normal file
42
custom_components/blueprint/sensor.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
"""Sensor platform for blueprint"""
|
||||||
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from . import update_data
|
||||||
|
from .const import * # pylint: disable=wildcard-import, unused-wildcard-import
|
||||||
|
|
||||||
|
ICON = 'mdi:format-quote-close'
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_platform(
|
||||||
|
hass, config, async_add_entities, discovery_info=None): # pylint: disable=unused-argument
|
||||||
|
"""Setup sensor platform."""
|
||||||
|
async_add_entities([blueprintSensor(hass)], True)
|
||||||
|
|
||||||
|
|
||||||
|
class blueprintSensor(Entity):
|
||||||
|
"""blueprint Sensor class."""
|
||||||
|
def __init__(self, hass):
|
||||||
|
self.hass = hass
|
||||||
|
self._state = None
|
||||||
|
|
||||||
|
async def async_update(self):
|
||||||
|
"""Update the sensor."""
|
||||||
|
await update_data(self.hass)
|
||||||
|
updated = self.hass.data[DOMAIN_DATA].get('compliment')
|
||||||
|
if updated is None:
|
||||||
|
updated = self._state
|
||||||
|
self._state = updated.capitalize()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the name of the sensor."""
|
||||||
|
return DOMAIN
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
"""Return the state of the sensor."""
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
"""Return the icon of the sensor."""
|
||||||
|
return ICON
|
4
resorces.json
Normal file
4
resorces.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[
|
||||||
|
"https://raw.githubusercontent.com/custom-components/blueprint/master/custom_components/blueprint/const.py",
|
||||||
|
"https://raw.githubusercontent.com/custom-components/blueprint/master/custom_components/blueprint/sensor.py"
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user