Etherscan.io sensor (#7855)

* etherscan sensor

* Update etherscan.py
pull/7843/merge
Nolan Gilley 2017-06-05 01:48:04 -04:00 committed by Paulus Schoutsen
parent 0646d01152
commit 6bfd52ada8
3 changed files with 59 additions and 0 deletions

View File

@ -393,6 +393,7 @@ omit =
homeassistant/components/sensor/eliqonline.py
homeassistant/components/sensor/emoncms.py
homeassistant/components/sensor/envirophat.py
homeassistant/components/sensor/etherscan.py
homeassistant/components/sensor/fastdotcom.py
homeassistant/components/sensor/fedex.py
homeassistant/components/sensor/fido.py

View File

@ -0,0 +1,55 @@
"""
Support for Etherscan sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.etherscan/
"""
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.helpers.entity import Entity
import homeassistant.helpers.config_validation as cv
import voluptuous as vol
REQUIREMENTS = ['python-etherscan-api==0.0.1']
CONF_ADDRESS = 'address'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_ADDRESS): cv.string
})
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the etherscan sensors."""
add_devices([EtherscanSensor('Ethereum Balance',
config.get(CONF_ADDRESS))])
class EtherscanSensor(Entity):
"""Representation of an Etherscan.io sensor."""
def __init__(self, name, address):
"""Initialize the sensor."""
self._name = name
self.address = address
self._state = None
self._unit_of_measurement = 'ETH'
self.update()
@property
def name(self):
"""Return the name of the sensor."""
return self._name
@property
def state(self):
"""Return the state of the sensor."""
return self._state
@property
def unit_of_measurement(self):
"""Return the unit of measurement this sensor expresses itself in."""
return self._unit_of_measurement
def update(self):
"""Get the latest state of the sensor."""
from pyetherscan import get_balance
self._state = get_balance(self.address)

View File

@ -657,6 +657,9 @@ python-ecobee-api==0.0.7
# homeassistant.components.climate.eq3btsmart
# python-eq3bt==0.1.5
# homeassistant.components.sensor.etherscan
python-etherscan-api==0.0.1
# homeassistant.components.sensor.darksky
python-forecastio==1.3.5