minor updates
This commit is contained in:
33
.github/main.workflow
vendored
33
.github/main.workflow
vendored
@ -1,19 +1,10 @@
|
|||||||
workflow "Trigger: Push to master from admin account" {
|
workflow "Trigger: Push to master from admin account" {
|
||||||
on = "push"
|
on = "push"
|
||||||
resolves = [
|
resolves = [
|
||||||
"HA Index",
|
"HA Index"
|
||||||
"push"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
workflow "Trigger: Push" {
|
|
||||||
on = "push"
|
|
||||||
resolves = [
|
|
||||||
"Black Code Formatter Check"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
action "branch-filter" {
|
action "branch-filter" {
|
||||||
uses = "actions/bin/filter@master"
|
uses = "actions/bin/filter@master"
|
||||||
args = "branch master"
|
args = "branch master"
|
||||||
@ -32,25 +23,3 @@ action "HA Index" {
|
|||||||
secrets = ["GITHUB_TOKEN"]
|
secrets = ["GITHUB_TOKEN"]
|
||||||
needs = ["branch-filter", "Access control"]
|
needs = ["branch-filter", "Access control"]
|
||||||
}
|
}
|
||||||
|
|
||||||
action "Black Code Formatter Fix" {
|
|
||||||
uses = "lgeiger/black-action@v1.0.1"
|
|
||||||
args = "$GITHUB_WORKSPACE"
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Black Code Formatter Check" {
|
|
||||||
uses = "lgeiger/black-action@v1.0.1"
|
|
||||||
args = "$GITHUB_WORKSPACE --check"
|
|
||||||
}
|
|
||||||
|
|
||||||
action "push" {
|
|
||||||
uses = "ludeeus/actions/push@master"
|
|
||||||
env = {
|
|
||||||
PUSHMAIL = "ludeeus@gmail.com"
|
|
||||||
PUSHNAME = "ludeeus"
|
|
||||||
PUSHBRANCH = "master"
|
|
||||||
PUSHMESSAGE = "Action commit"
|
|
||||||
}
|
|
||||||
needs = ["Black Code Formatter Fix"]
|
|
||||||
secrets = ["GITHUB_TOKEN"]
|
|
||||||
}
|
|
@ -36,7 +36,6 @@ custom_components/blueprint/sensor.py
|
|||||||
blueprint:
|
blueprint:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
[exampleimg]: example.png
|
[exampleimg]: example.png
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Component to integrate with https://blueprint.com/api
|
Component to integrate with blueprint
|
||||||
|
|
||||||
For more details about this component, please refer to
|
For more details about this component, please refer to
|
||||||
https://github.com/custom-components/blueprint
|
https://github.com/custom-components/blueprint
|
||||||
@ -8,10 +8,10 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
from .const import (
|
||||||
|
DOMAIN_DATA, DOMAIN, ISSUE_URL, PLATFORMS, REQUIRED_FILES, STARTUP, URL,
|
||||||
|
VERSION)
|
||||||
|
|
||||||
from .const import * # pylint: disable=wildcard-import
|
|
||||||
|
|
||||||
VERSION = "0.0.1"
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -42,6 +42,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
async def update_data(hass):
|
async def update_data(hass):
|
||||||
"""Update data."""
|
"""Update data."""
|
||||||
|
# This is where the main logic to update platform data goes.
|
||||||
try:
|
try:
|
||||||
request = requests.get(URL)
|
request = requests.get(URL)
|
||||||
jsondata = request.json()
|
jsondata = request.json()
|
||||||
@ -52,6 +53,7 @@ async def update_data(hass):
|
|||||||
|
|
||||||
async def check_files(hass):
|
async def check_files(hass):
|
||||||
"""Retrun bool that idicate that all files are present."""
|
"""Retrun bool that idicate that all files are present."""
|
||||||
|
# Verify that the user downloaded all files.
|
||||||
base = "{}/custom_components/{}/".format(hass.config.path(), DOMAIN)
|
base = "{}/custom_components/{}/".format(hass.config.path(), DOMAIN)
|
||||||
missing = []
|
missing = []
|
||||||
for file in REQUIRED_FILES:
|
for file in REQUIRED_FILES:
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""Consts"""
|
"""Conststants."""
|
||||||
|
# Base component constants
|
||||||
DOMAIN = "blueprint"
|
DOMAIN = "blueprint"
|
||||||
DOMAIN_DATA = "{}_data".format(DOMAIN)
|
DOMAIN_DATA = "{}_data".format(DOMAIN)
|
||||||
VERSION = "0.0.1"
|
VERSION = "0.0.1"
|
||||||
URL = "https://blueprint.com/api"
|
PLATFORMS = ["sensor"]
|
||||||
REQUIRED_FILES = ["sensor.py", "const.py"]
|
REQUIRED_FILES = ["sensor.py", "const.py"]
|
||||||
ISSUE_URL = "https://github.com/custom-components/blueprint/issues"
|
ISSUE_URL = "https://github.com/custom-components/blueprint/issues"
|
||||||
PLATFORMS = ["sensor"]
|
|
||||||
|
|
||||||
STARTUP = """
|
STARTUP = """
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
@ -16,3 +16,9 @@ If you have any issues with this you need to open an issue here:
|
|||||||
{issueurl}
|
{issueurl}
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Operational
|
||||||
|
URL = 'https://jsonplaceholder.typicode.com/todos/1'
|
||||||
|
|
||||||
|
# Icons
|
||||||
|
SENSOR_ICON = "mdi:format-quote-close"
|
||||||
|
@ -1,37 +1,47 @@
|
|||||||
"""Sensor platform for blueprint"""
|
"""Sensor platform for blueprint"""
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from . import update_data
|
from . import update_data
|
||||||
from .const import * # pylint: disable=wildcard-import, unused-wildcard-import
|
from .const import DOMAIN as NAME, DOMAIN_DATA, SENSOR_ICON
|
||||||
|
|
||||||
ICON = "mdi:format-quote-close"
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass, config, async_add_entities, discovery_info=None
|
hass, config, async_add_entities, discovery_info=None
|
||||||
): # pylint: disable=unused-argument
|
): # pylint: disable=unused-argument
|
||||||
"""Setup sensor platform."""
|
"""Setup sensor platform."""
|
||||||
async_add_entities([blueprintSensor(hass)], True)
|
async_add_entities([BlueprintSensor(hass)], True)
|
||||||
|
|
||||||
|
|
||||||
class blueprintSensor(Entity):
|
class BlueprintSensor(Entity):
|
||||||
"""blueprint Sensor class."""
|
"""blueprint Sensor class."""
|
||||||
|
|
||||||
def __init__(self, hass):
|
def __init__(self, hass):
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
|
self.attr = {}
|
||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
|
# Send update "signal" to the component
|
||||||
await update_data(self.hass)
|
await update_data(self.hass)
|
||||||
updated = self.hass.data[DOMAIN_DATA].get("compliment")
|
|
||||||
if updated is None:
|
# Get new data (if any)
|
||||||
|
updated = self.hass.data[DOMAIN_DATA]
|
||||||
|
|
||||||
|
# Check if there is data
|
||||||
|
if updated.get("title") is None:
|
||||||
updated = self._state
|
updated = self._state
|
||||||
|
|
||||||
|
# Set/update the state, and make sure it looks good by capitalizing it
|
||||||
self._state = updated.capitalize()
|
self._state = updated.capitalize()
|
||||||
|
|
||||||
|
# Set/update attributes
|
||||||
|
self.attr['user_id'] = updated.get('userId')
|
||||||
|
self.attr['completed'] = updated.get('completed')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return DOMAIN
|
return NAME
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
@ -41,4 +51,9 @@ class blueprintSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon of the sensor."""
|
"""Return the icon of the sensor."""
|
||||||
return ICON
|
return SENSOR_ICON
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the state attributes."""
|
||||||
|
return self.attr
|
||||||
|
BIN
example.png
Normal file
BIN
example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
Reference in New Issue
Block a user