original_docstring: Get updated data from SimpliSafe.
docstring: Get updated data from SimpliSafe.
docstring_tokens: Get updated data from SimpliSafe .
code: async def async_update(self):
          """Get updated data from SimpliSafe."""
  
          async def update_system(system):
              """Update a system."""
              await system.update()
              self.last_event_data[system.system_id] = await system.get_latest_event()
  
          tasks = [update_system(system) for system in self.systems.values()]
  
          def cancel_tasks():
              """Cancel tasks and ensure their cancellation is processed."""
              for task in tasks:
                  task.cancel()
  
          try:
              await asyncio.gather(*tasks)
          except InvalidCredentialsError:
              cancel_tasks()
  
              if self._emergency_refresh_token_used:
                  _LOGGER.error(
                      "SimpliSafe authentication disconnected. Please restart HASS."
                  )
                  remove_listener = self._hass.data[DOMAIN][DATA_LISTENER].pop(
                      self._config_entry.entry_id
                  )
                  remove_listener()
                  return
  
              _LOGGER.warning("SimpliSafe cloud error; trying stored refresh token")
              self._emergency_refresh_token_used = True
              return await self._api.refresh_access_token(
                  self._config_entry.data[CONF_TOKEN]
              )
          except SimplipyError as err:
              cancel_tasks()
              _LOGGER.error("SimpliSafe error while updating: %s", err)
              return
          except Exception as err:  # pylint: disable=broad-except
              cancel_tasks()
              _LOGGER.error("Unknown error while updating: %s", err)
              return
  
          if self._api.refresh_token_dirty:
              _async_save_refresh_token(
                  self._hass, self._config_entry, self._api.refresh_token
              )
  
          # If we've reached this point using an emergency refresh token, we're in the
          # clear and we can discard it:
          if self._emergency_refresh_token_used:
              self._emergency_refresh_token_used = False
  
          _LOGGER.debug("Updated data for all SimpliSafe systems")
          async_dispatcher_send(self._hass, TOPIC_UPDATE)
code_tokens: async def async_update ( self ) : async def update_system ( system ) : """Update a system.""" await system . update ( ) self . last_event_data [ system . system_id ] = await system . get_latest_event ( ) tasks = [ update_system ( system ) for system in self . systems . values ( ) ] def cancel_tasks ( ) : """Cancel tasks and ensure their cancellation is processed.""" for task in tasks : task . cancel ( ) try : await asyncio . gather ( * tasks ) except InvalidCredentialsError : cancel_tasks ( ) if self . _emergency_refresh_token_used : _LOGGER . error ( "SimpliSafe authentication disconnected. Please restart HASS." ) remove_listener = self . _hass . data [ DOMAIN ] [ DATA_LISTENER ] . pop ( self . _config_entry . entry_id ) remove_listener ( ) return _LOGGER . warning ( "SimpliSafe cloud error; trying stored refresh token" ) self . _emergency_refresh_token_used = True return await self . _api . refresh_access_token ( self . _config_entry . data [ CONF_TOKEN ] ) except SimplipyError as err : cancel_tasks ( ) _LOGGER . error ( "SimpliSafe error while updating: %s" , err ) return except Exception as err : cancel_tasks ( ) _LOGGER . error ( "Unknown error while updating: %s" , err ) return if self . _api . refresh_token_dirty : _async_save_refresh_token ( self . _hass , self . _config_entry , self . _api . refresh_token ) if self . _emergency_refresh_token_used : self . _emergency_refresh_token_used = False _LOGGER . debug ( "Updated data for all SimpliSafe systems" ) async_dispatcher_send ( self . _hass , TOPIC_UPDATE )
short_docstring: Get updated data from SimpliSafe.
short_docstring_tokens: Get updated data from SimpliSafe .
comment: """Get updated data from SimpliSafe."""$SEP$"""Update a system."""$SEP$"""Cancel tasks and ensure their cancellation is processed."""$SEP$# pylint: disable=broad-except$SEP$# If we've reached this point using an emergency refresh token, we're in the$SEP$# clear and we can discard it: