1 """Support for Etherscan sensors."""
3 from __future__
import annotations
5 from datetime
import timedelta
7 from pyetherscan
import get_balance
8 import voluptuous
as vol
11 PLATFORM_SCHEMA
as SENSOR_PLATFORM_SCHEMA,
20 CONF_TOKEN_ADDRESS =
"token_address"
24 PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
26 vol.Required(CONF_ADDRESS): cv.string,
27 vol.Optional(CONF_NAME): cv.string,
28 vol.Optional(CONF_TOKEN): cv.string,
29 vol.Optional(CONF_TOKEN_ADDRESS): cv.string,
37 add_entities: AddEntitiesCallback,
38 discovery_info: DiscoveryInfoType |
None =
None,
40 """Set up the Etherscan.io sensors."""
41 address = config.get(CONF_ADDRESS)
42 name = config.get(CONF_NAME)
43 token = config.get(CONF_TOKEN)
44 token_address = config.get(CONF_TOKEN_ADDRESS)
49 name = f
"{token} Balance"
57 """Representation of an Etherscan.io sensor."""
59 _attr_attribution =
"Data provided by etherscan.io"
61 def __init__(self, name, address, token, token_address):
62 """Initialize the sensor."""
72 """Return the name of the sensor."""
73 return self.
_name_name
77 """Return the state of the sensor."""
82 """Return the unit of measurement this sensor expresses itself in."""
86 """Get the latest state of the sensor."""
def __init__(self, name, address, token, token_address)
def native_unit_of_measurement(self)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)
def add_entities(account, async_add_entities, tracked)