Action commit
This commit is contained in:
@ -11,10 +11,11 @@ from homeassistant.helpers import discovery
|
|||||||
|
|
||||||
from .const import * # pylint: disable=wildcard-import
|
from .const import * # pylint: disable=wildcard-import
|
||||||
|
|
||||||
VERSION = '0.0.1'
|
VERSION = "0.0.1"
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass, config):
|
||||||
"""Set up this component."""
|
"""Set up this component."""
|
||||||
@ -34,7 +35,8 @@ async def async_setup(hass, config):
|
|||||||
# Load platforms
|
# Load platforms
|
||||||
for platform in PLATFORMS:
|
for platform in PLATFORMS:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, platform, DOMAIN, {}, config))
|
discovery.async_load_platform(hass, platform, DOMAIN, {}, config)
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""Consts"""
|
"""Consts"""
|
||||||
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'
|
URL = "https://blueprint.com/api"
|
||||||
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']
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
STARTUP = """
|
STARTUP = """
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
@ -3,17 +3,19 @@ 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 * # pylint: disable=wildcard-import, unused-wildcard-import
|
||||||
|
|
||||||
ICON = 'mdi:format-quote-close'
|
ICON = "mdi:format-quote-close"
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass, config, async_add_entities, discovery_info=None): # pylint: disable=unused-argument
|
hass, config, async_add_entities, discovery_info=None
|
||||||
|
): # 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._state = None
|
self._state = None
|
||||||
@ -21,7 +23,7 @@ class blueprintSensor(Entity):
|
|||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
await update_data(self.hass)
|
await update_data(self.hass)
|
||||||
updated = self.hass.data[DOMAIN_DATA].get('compliment')
|
updated = self.hass.data[DOMAIN_DATA].get("compliment")
|
||||||
if updated is None:
|
if updated is None:
|
||||||
updated = self._state
|
updated = self._state
|
||||||
self._state = updated.capitalize()
|
self._state = updated.capitalize()
|
||||||
|
Reference in New Issue
Block a user