Upgrade pyota to 2.0.5 (#14442)

* Use constants

* Upgrade pyota to 2.0.5
This commit is contained in:
Fabian Affolter 2018-05-13 17:58:57 +02:00 committed by Pascal Vizeli
parent 3ec56d55c5
commit e0bc894cbb
3 changed files with 19 additions and 11 deletions

View File

@ -13,7 +13,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import load_platform from homeassistant.helpers.discovery import load_platform
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['pyota==2.0.4'] REQUIREMENTS = ['pyota==2.0.5']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -7,10 +7,18 @@ https://home-assistant.io/components/iota
import logging import logging
from datetime import timedelta from datetime import timedelta
from homeassistant.components.iota import IotaDevice from homeassistant.components.iota import IotaDevice, CONF_WALLETS
from homeassistant.const import CONF_NAME
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTR_TESTNET = 'testnet'
ATTR_URL = 'url'
CONF_IRI = 'iri'
CONF_SEED = 'seed'
CONF_TESTNET = 'testnet'
DEPENDENCIES = ['iota'] DEPENDENCIES = ['iota']
SCAN_INTERVAL = timedelta(minutes=3) SCAN_INTERVAL = timedelta(minutes=3)
@ -21,7 +29,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# Add sensors for wallet balance # Add sensors for wallet balance
iota_config = discovery_info iota_config = discovery_info
sensors = [IotaBalanceSensor(wallet, iota_config) sensors = [IotaBalanceSensor(wallet, iota_config)
for wallet in iota_config['wallets']] for wallet in iota_config[CONF_WALLETS]]
# Add sensor for node information # Add sensor for node information
sensors.append(IotaNodeSensor(iota_config=iota_config)) sensors.append(IotaNodeSensor(iota_config=iota_config))
@ -34,10 +42,9 @@ class IotaBalanceSensor(IotaDevice):
def __init__(self, wallet_config, iota_config): def __init__(self, wallet_config, iota_config):
"""Initialize the sensor.""" """Initialize the sensor."""
super().__init__(name=wallet_config['name'], super().__init__(
seed=wallet_config['seed'], name=wallet_config[CONF_NAME], seed=wallet_config[CONF_SEED],
iri=iota_config['iri'], iri=iota_config[CONF_IRI], is_testnet=iota_config[CONF_TESTNET])
is_testnet=iota_config['testnet'])
self._state = None self._state = None
@property @property
@ -65,10 +72,11 @@ class IotaNodeSensor(IotaDevice):
def __init__(self, iota_config): def __init__(self, iota_config):
"""Initialize the sensor.""" """Initialize the sensor."""
super().__init__(name='Node Info', seed=None, iri=iota_config['iri'], super().__init__(
is_testnet=iota_config['testnet']) name='Node Info', seed=None, iri=iota_config[CONF_IRI],
is_testnet=iota_config[CONF_TESTNET])
self._state = None self._state = None
self._attr = {'url': self.iri, 'testnet': self.is_testnet} self._attr = {ATTR_URL: self.iri, ATTR_TESTNET: self.is_testnet}
@property @property
def name(self): def name(self):

View File

@ -891,7 +891,7 @@ pynut2==2.1.2
pynx584==0.4 pynx584==0.4
# homeassistant.components.iota # homeassistant.components.iota
pyota==2.0.4 pyota==2.0.5
# homeassistant.components.sensor.otp # homeassistant.components.sensor.otp
pyotp==2.2.6 pyotp==2.2.6