Move imports in dweet component (#27976)
This commit is contained in:
parent
9db07b2a41
commit
54a711ca6a
2 changed files with 9 additions and 13 deletions
|
@ -1,7 +1,8 @@
|
||||||
"""Support for sending data to Dweet.io."""
|
"""Support for sending data to Dweet.io."""
|
||||||
import logging
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import dweepy
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -10,8 +11,8 @@ from homeassistant.const import (
|
||||||
EVENT_STATE_CHANGED,
|
EVENT_STATE_CHANGED,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers import state as state_helper
|
from homeassistant.helpers import state as state_helper
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -69,8 +70,6 @@ def setup(hass, config):
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def send_data(name, msg):
|
def send_data(name, msg):
|
||||||
"""Send the collected data to Dweet.io."""
|
"""Send the collected data to Dweet.io."""
|
||||||
import dweepy
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dweepy.dweet_for(name, msg)
|
dweepy.dweet_for(name, msg)
|
||||||
except dweepy.DweepyError:
|
except dweepy.DweepyError:
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
"""Support for showing values from Dweet.io."""
|
"""Support for showing values from Dweet.io."""
|
||||||
|
from datetime import timedelta
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
|
import dweepy
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME,
|
|
||||||
CONF_VALUE_TEMPLATE,
|
|
||||||
CONF_UNIT_OF_MEASUREMENT,
|
|
||||||
CONF_DEVICE,
|
CONF_DEVICE,
|
||||||
|
CONF_NAME,
|
||||||
|
CONF_UNIT_OF_MEASUREMENT,
|
||||||
|
CONF_VALUE_TEMPLATE,
|
||||||
)
|
)
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -33,8 +34,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Dweet sensor."""
|
"""Set up the Dweet sensor."""
|
||||||
import dweepy
|
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
device = config.get(CONF_DEVICE)
|
device = config.get(CONF_DEVICE)
|
||||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||||
|
@ -107,8 +106,6 @@ class DweetData:
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data from Dweet.io."""
|
"""Get the latest data from Dweet.io."""
|
||||||
import dweepy
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.data = dweepy.get_latest_dweet_for(self._device)
|
self.data = dweepy.get_latest_dweet_for(self._device)
|
||||||
except dweepy.DweepyError:
|
except dweepy.DweepyError:
|
||||||
|
|
Loading…
Add table
Reference in a new issue