tibber/__init__.py
async def update_price_info(self):
        """Update price info async."""
        query = gql(
            """
        {
          viewer {
            home(id: "%s") {
              currentSubscription {
                priceInfo {
                  current {
                    energy
                    tax
                    total
                    startsAt
                    level
                  }
                  today {
                    total
                    startsAt
                    level
                  }
                  tomorrow {
                    total
                    startsAt
                    level
                  }
                }
              }
            }
          }
        }
        """
            % self.home_id
        )
        price_info_temp = await self._tibber_control.execute(query)
        if not price_info_temp:
            _LOGGER.error("Could not find price info.")
            return
        self._price_info = {}
        self._level_info = {}
        for key in ["current", "today", "tomorrow"]:
            try:
                home = price_info_temp["viewer"]["home"]
                current_subscription = home["currentSubscription"]
                price_info = current_subscription["priceInfo"][key]
            except (KeyError, TypeError):
                _LOGGER.error("Could not find price info for %s.", key)
                continue
            if key == "current":
                self._current_price_info = price_info
                continue
            for data in price_info:
                self._price_info[data.get("startsAt")] = data.get("total")
                self._level_info[data.get("startsAt")] = data.get("level")
async def update_price_info(self):
        """Update price info async."""
        query = gql(
            """
        {
          viewer {
            home(id: "%s") {
              currentSubscription {
                priceInfo {
                  current {
                    energy
                    tax
                    total
                    startsAt
                    level
                  }
                  today {
                    total
                    startsAt
                    level
                  }
                  tomorrow {
                    total
                    startsAt
                    level
                  }
                }
              }
            }
          }
        }
        """
            % self.home_id
        )
        price_info_temp = await self._tibber_control.execute(query)
        if not price_info_temp:
            _LOGGER.error("Could not find price info.")
            return
        self._price_info = {}
        self._level_info = {}
        for key in ["current", "today", "tomorrow"]:
            try:
                home = price_info_temp["viewer"]["home"]
                current_subscription = home["currentSubscription"]
                price_info = current_subscription["priceInfo"][key]
            except (KeyError, TypeError):
                _LOGGER.error("Could not find price info for %s.", key)
                continue
            if key == "current":
                self._current_price_info = price_info
                continue
            for data in price_info:
                self._price_info[data.get("startsAt")] = data.get("total")
                self._level_info[data.get("startsAt")] = data.get("level")
async def update_price_info ( self ) : query = gql ( """
        {
          viewer {
            home(id: "%s") {
              currentSubscription {
                priceInfo {
                  current {
                    energy
                    tax
                    total
                    startsAt
                    level
                  }
                  today {
                    total
                    startsAt
                    level
                  }
                  tomorrow {
                    total
                    startsAt
                    level
                  }
                }
              }
            }
          }
        }
        """ % self . home_id ) price_info_temp = await self . _tibber_control . execute ( query ) if not price_info_temp : _LOGGER . error ( "Could not find price info." ) return self . _price_info = { } self . _level_info = { } for key in [ "current" , "today" , "tomorrow" ] : try : home = price_info_temp [ "viewer" ] [ "home" ] current_subscription = home [ "currentSubscription" ] price_info = current_subscription [ "priceInfo" ] [ key ] except ( KeyError , TypeError ) : _LOGGER . error ( "Could not find price info for %s." , key ) continue if key == "current" : self . _current_price_info = price_info continue for data in price_info : self . _price_info [ data . get ( "startsAt" ) ] = data . get ( "total" ) self . _level_info [ data . get ( "startsAt" ) ] = data . get ( "level" )
Update price info async.
Update price info async .