custom_components/yahoofinance/sensor.py
def fetch_data(self) -> None:
        """Fetch data and populate local fields."""
        data = self._coordinator.data
        if data is None:
            return

        symbol_data = data[self._symbol]
        if symbol_data is None:
            return

        self._short_name = symbol_data["shortName"]
        self._state = symbol_data["regularMarketPrice"]
        self._fifty_day_average = symbol_data["fiftyDayAverage"]
        self._previous_close = symbol_data["regularMarketPreviousClose"]

        currency = symbol_data["financialCurrency"]
        if currency is None:
            currency = symbol_data.get("currency", DEFAULT_CURRENCY)

        self._currency = currency.upper()
        lower_currency = self._currency.lower()
        self._icon = "mdi:currency-" + lower_currency
        if lower_currency in CURRENCY_CODES:
            self._icon = "mdi:currency-" + lower_currency
            self._currency_symbol = CURRENCY_CODES[lower_currency]
Fetch data and populate local fields.
Fetch data and populate local fields.
Fetch data and populate local fields .
def fetch_data(self) -> None:
        data = self._coordinator.data
        if data is None:
            return
        symbol_data = data[self._symbol]
        if symbol_data is None:
            return
        self._short_name = symbol_data["shortName"]
        self._state = symbol_data["regularMarketPrice"]
        self._fifty_day_average = symbol_data["fiftyDayAverage"]
        self._previous_close = symbol_data["regularMarketPreviousClose"]
        currency = symbol_data["financialCurrency"]
        if currency is None:
            currency = symbol_data.get("currency", DEFAULT_CURRENCY)
        self._currency = currency.upper()
        lower_currency = self._currency.lower()
        self._icon = "mdi:currency-" + lower_currency
        if lower_currency in CURRENCY_CODES:
            self._icon = "mdi:currency-" + lower_currency
            self._currency_symbol = CURRENCY_CODES[lower_currency]
def fetch_data ( self ) -> None : data = self . _coordinator . data if data is None : return symbol_data = data [ self . _symbol ] if symbol_data is None : return self . _short_name = symbol_data [ "shortName" ] self . _state = symbol_data [ "regularMarketPrice" ] self . _fifty_day_average = symbol_data [ "fiftyDayAverage" ] self . _previous_close = symbol_data [ "regularMarketPreviousClose" ] currency = symbol_data [ "financialCurrency" ] if currency is None : currency = symbol_data . get ( "currency" , DEFAULT_CURRENCY ) self . _currency = currency . upper ( ) lower_currency = self . _currency . lower ( ) self . _icon = "mdi:currency-" + lower_currency if lower_currency in CURRENCY_CODES : self . _icon = "mdi:currency-" + lower_currency self . _currency_symbol = CURRENCY_CODES [ lower_currency ]
Fetch data and populate local fields.
Fetch data and populate local fields .
"""Fetch data and populate local fields."""
self