minor updates

This commit is contained in:
ludeeus 2019-03-08 22:12:01 +01:00
parent 08fbf028d3
commit ce2d663821
7 changed files with 41 additions and 50 deletions

33
.github/main.workflow vendored
View File

@ -1,19 +1,10 @@
workflow "Trigger: Push to master from admin account" {
on = "push"
resolves = [
"HA Index",
"push"
"HA Index"
]
}
workflow "Trigger: Push" {
on = "push"
resolves = [
"Black Code Formatter Check"
]
}
action "branch-filter" {
uses = "actions/bin/filter@master"
args = "branch master"
@ -31,26 +22,4 @@ action "HA Index" {
uses = "ludeeus/actions/haindex@master"
secrets = ["GITHUB_TOKEN"]
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"]
}

View File

@ -36,7 +36,6 @@ custom_components/blueprint/sensor.py
blueprint:
```
***
[exampleimg]: example.png

View File

@ -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
https://github.com/custom-components/blueprint
@ -8,10 +8,10 @@ import os
import logging
import requests
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__)
# pylint: disable=unused-argument
@ -42,6 +42,7 @@ async def async_setup(hass, config):
async def update_data(hass):
"""Update data."""
# This is where the main logic to update platform data goes.
try:
request = requests.get(URL)
jsondata = request.json()
@ -52,6 +53,7 @@ async def update_data(hass):
async def check_files(hass):
"""Retrun bool that idicate that all files are present."""
# Verify that the user downloaded all files.
base = "{}/custom_components/{}/".format(hass.config.path(), DOMAIN)
missing = []
for file in REQUIRED_FILES:

View File

@ -1,11 +1,11 @@
"""Consts"""
"""Conststants."""
# Base component constants
DOMAIN = "blueprint"
DOMAIN_DATA = "{}_data".format(DOMAIN)
VERSION = "0.0.1"
URL = "https://blueprint.com/api"
PLATFORMS = ["sensor"]
REQUIRED_FILES = ["sensor.py", "const.py"]
ISSUE_URL = "https://github.com/custom-components/blueprint/issues"
PLATFORMS = ["sensor"]
STARTUP = """
----------------------------------------------
@ -16,3 +16,9 @@ If you have any issues with this you need to open an issue here:
{issueurl}
----------------------------------------------
"""
# Operational
URL = 'https://jsonplaceholder.typicode.com/todos/1'
# Icons
SENSOR_ICON = "mdi:format-quote-close"

View File

@ -1,37 +1,47 @@
"""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"
from .const import DOMAIN as NAME, DOMAIN_DATA, SENSOR_ICON
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
"""Setup sensor platform."""
async_add_entities([blueprintSensor(hass)], True)
async_add_entities([BlueprintSensor(hass)], True)
class blueprintSensor(Entity):
class BlueprintSensor(Entity):
"""blueprint Sensor class."""
def __init__(self, hass):
self.hass = hass
self.attr = {}
self._state = None
async def async_update(self):
"""Update the sensor."""
# Send update "signal" to the component
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
# Set/update the state, and make sure it looks good by capitalizing it
self._state = updated.capitalize()
# Set/update attributes
self.attr['user_id'] = updated.get('userId')
self.attr['completed'] = updated.get('completed')
@property
def name(self):
"""Return the name of the sensor."""
return DOMAIN
return NAME
@property
def state(self):
@ -41,4 +51,9 @@ class blueprintSensor(Entity):
@property
def icon(self):
"""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

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

BIN
image.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB