mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Cleanup blockchain sensor (#80077)
This commit is contained in:
parent
69d935b7bd
commit
6f7cb158d8
@ -66,6 +66,7 @@ homeassistant.components.backup.*
|
|||||||
homeassistant.components.baf.*
|
homeassistant.components.baf.*
|
||||||
homeassistant.components.bayesian.*
|
homeassistant.components.bayesian.*
|
||||||
homeassistant.components.binary_sensor.*
|
homeassistant.components.binary_sensor.*
|
||||||
|
homeassistant.components.blockchain.*
|
||||||
homeassistant.components.bluetooth.*
|
homeassistant.components.bluetooth.*
|
||||||
homeassistant.components.bluetooth_tracker.*
|
homeassistant.components.bluetooth_tracker.*
|
||||||
homeassistant.components.bmw_connected_drive.*
|
homeassistant.components.bmw_connected_drive.*
|
||||||
|
@ -8,7 +8,7 @@ from pyblockchain import get_balance, validate_address
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -16,14 +16,10 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTRIBUTION = "Data provided by blockchain.com"
|
|
||||||
|
|
||||||
CONF_ADDRESSES = "addresses"
|
CONF_ADDRESSES = "addresses"
|
||||||
|
|
||||||
DEFAULT_NAME = "Bitcoin Balance"
|
DEFAULT_NAME = "Bitcoin Balance"
|
||||||
|
|
||||||
ICON = "mdi:currency-btc"
|
|
||||||
|
|
||||||
SCAN_INTERVAL = timedelta(minutes=5)
|
SCAN_INTERVAL = timedelta(minutes=5)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
@ -42,8 +38,8 @@ def setup_platform(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Blockchain.com sensors."""
|
"""Set up the Blockchain.com sensors."""
|
||||||
|
|
||||||
addresses = config[CONF_ADDRESSES]
|
addresses: list[str] = config[CONF_ADDRESSES]
|
||||||
name = config[CONF_NAME]
|
name: str = config[CONF_NAME]
|
||||||
|
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
if not validate_address(address):
|
if not validate_address(address):
|
||||||
@ -56,11 +52,11 @@ def setup_platform(
|
|||||||
class BlockchainSensor(SensorEntity):
|
class BlockchainSensor(SensorEntity):
|
||||||
"""Representation of a Blockchain.com sensor."""
|
"""Representation of a Blockchain.com sensor."""
|
||||||
|
|
||||||
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
_attr_attribution = "Data provided by blockchain.com"
|
||||||
_attr_icon = ICON
|
_attr_icon = "mdi:currency-btc"
|
||||||
_attr_native_unit_of_measurement = "BTC"
|
_attr_native_unit_of_measurement = "BTC"
|
||||||
|
|
||||||
def __init__(self, name, addresses):
|
def __init__(self, name: str, addresses: list[str]) -> None:
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._attr_name = name
|
self._attr_name = name
|
||||||
self.addresses = addresses
|
self.addresses = addresses
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -412,6 +412,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.blockchain.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.bluetooth.*]
|
[mypy-homeassistant.components.bluetooth.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user