Maintenance 2nd (#4106)
* Add link to docs * Fix link * Update line breaks * Update ordering * Align vera platofrm to only use add_devices (instead od add_devices_callback) * Remove line break * Use consts * Update ordering * Update ordering * Use const, create default name, use string formatting * Update ordering * Use const * Update import style * Update ordering and line breaks * update line breaks * Set default port * Set defaults and update ordering * Update ordering * Minor style updates * Update ordering, defaults, line breaks, and readability * Use constants * Add line breaks * use string formatting * Update line breaks * Update logger
This commit is contained in:
1 parent
e6ece4bf6d
commit
9f2aae1357
28 files changed
+272
-271
No files matched your search
@@ -1,12 +1,16 @@
|
||||
"""A component to submit data to thingspeak."""
|
||||
"""
|
||||
A component to submit data to thingspeak.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/thingspeak/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
from requests.exceptions import RequestException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY, CONF_ID, CONF_WHITELIST,
|
||||
STATE_UNAVAILABLE, STATE_UNKNOWN)
|
||||
CONF_API_KEY, CONF_ID, CONF_WHITELIST, STATE_UNAVAILABLE, STATE_UNKNOWN)
|
||||
from homeassistant.helpers import state as state_helper
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.helpers.event as event
|
||||
@@ -16,23 +20,22 @@ REQUIREMENTS = ['thingspeak==0.4.0']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DOMAIN = 'thingspeak'
|
||||
|
||||
TIMEOUT = 5
|
||||
|
||||
# Validate the config
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_API_KEY): cv.string,
|
||||
vol.Required(CONF_ID): int,
|
||||
vol.Required(CONF_WHITELIST): cv.string
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the thingspeak environment."""
|
||||
"""Set up the Thingspeak environment."""
|
||||
import thingspeak
|
||||
|
||||
# Read out config values
|
||||
conf = config[DOMAIN]
|
||||
api_key = conf.get(CONF_API_KEY)
|
||||
channel_id = conf.get(CONF_ID)
|
||||
@@ -62,9 +65,8 @@ def setup(hass, config):
|
||||
try:
|
||||
channel.update({'field1': _state})
|
||||
except RequestException:
|
||||
_LOGGER.error(
|
||||
'Error while sending value "%s" to Thingspeak',
|
||||
_state)
|
||||
_LOGGER.error("Error while sending value '%s' to Thingspeak",
|
||||
_state)
|
||||
|
||||
event.track_state_change(hass, entity, thingspeak_listener)
|
||||
|
||||
|
||||
Reference in new issue
Block a user