custom_components/yahoofinance/sensor.py
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):  # pylint: disable=unused-argument
    """Set up the Yahoo Finance sensors."""
    symbols = config.get(CONF_SYMBOLS, [])
    coordinator = YahooSymbolUpdateCoordinator(
        symbols, hass, config.get(CONF_SCAN_INTERVAL)
    )
    await coordinator.async_refresh()

    sensors = []
    for symbol in symbols:
        sensors.append(YahooFinanceSensor(coordinator, symbol, hass))

    # The True param fetches data first time before being written to HA
    async_add_entities(sensors, True)

    async def handle_refresh_symbols(_call):
        """Refresh symbol data."""
        _LOGGER.info("Processing refresh_symbols")
        await coordinator.async_request_refresh()

    hass.services.async_register(
        DOMAIN, SERVICE_REFRESH, handle_refresh_symbols,
    )

    _LOGGER.info("Added sensors for %s", symbols)
Set up the Yahoo Finance sensors.
Set up the Yahoo Finance sensors.
Set up the Yahoo Finance sensors .
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):  
    symbols = config.get(CONF_SYMBOLS, [])
    coordinator = YahooSymbolUpdateCoordinator(
        symbols, hass, config.get(CONF_SCAN_INTERVAL)
    )
    await coordinator.async_refresh()
    sensors = []
    for symbol in symbols:
        sensors.append(YahooFinanceSensor(coordinator, symbol, hass))
    async_add_entities(sensors, True)
    async def handle_refresh_symbols(_call):
        _LOGGER.info("Processing refresh_symbols")
        await coordinator.async_request_refresh()
    hass.services.async_register(
        DOMAIN, SERVICE_REFRESH, handle_refresh_symbols,
    )
    _LOGGER.info("Added sensors for %s", symbols)
async def async_setup_platform ( hass , config , async_add_entities , discovery_info = None ) : symbols = config . get ( CONF_SYMBOLS , [ ] ) coordinator = YahooSymbolUpdateCoordinator ( symbols , hass , config . get ( CONF_SCAN_INTERVAL ) ) await coordinator . async_refresh ( ) sensors = [ ] for symbol in symbols : sensors . append ( YahooFinanceSensor ( coordinator , symbol , hass ) ) async_add_entities ( sensors , True ) async def handle_refresh_symbols ( _call ) : """Refresh symbol data.""" _LOGGER . info ( "Processing refresh_symbols" ) await coordinator . async_request_refresh ( ) hass . services . async_register ( DOMAIN , SERVICE_REFRESH , handle_refresh_symbols , ) _LOGGER . info ( "Added sensors for %s" , symbols )
Set up the Yahoo Finance sensors.
Set up the Yahoo Finance sensors .
# pylint: disable=unused-argument """Set up the Yahoo Finance sensors.""" # The True param fetches data first time before being written to HA """Refresh symbol data."""
hass
config
async_add_entities
discovery_info