code: def status(self, pubnub, status):
          
          if status.operation == PNOperationType.PNSubscribeOperation \
              or status.operation == PNOperationType.PNUnsubscribeOperation:
              if status.category == PNStatusCategory.PNConnectedCategory:
                  # This is expected for a subscribe, this means there is no error or issue whatsoever
                  _LOGGER.info("PubNub connected")
              elif status.category == PNStatusCategory.PNReconnectedCategory:
                  # This usually occurs if subscribe temporarily fails but reconnects. This means
                  # there was an error but there is no longer any issue
                  _LOGGER.info("PubNub reconnected")
              elif status.category == PNStatusCategory.PNDisconnectedCategory:
                  # This is the expected category for an unsubscribe. This means there
                  # was no error in unsubscribing from everything
                  _LOGGER.info("PubNub unsubscribed")
              elif status.category == PNStatusCategory.PNUnexpectedDisconnectCategory:
                  # This is usually an issue with the internet connection, this is an error, handle appropriately
                  # retry will be called automatically
                  _LOGGER.info("PubNub disconnected (lost internet?)")
              else:
                  # This is usually an issue with the internet connection, this is an error, handle appropriately
                  # retry will be called automatically
                  _LOGGER.info("PubNub disconnected (lost internet?)")
          elif status.operation == PNOperationType.PNHeartbeatOperation:
              # Heartbeat operations can in fact have errors, so it is important to check first for an error.
              # For more information on how to configure heartbeat notifications through the status
              # PNObjectEventListener callback, consult <link to the PNCONFIGURATION heartbeart config>
              if status.is_error():
                  # There was an error with the heartbeat operation, handle here
                  _LOGGER.info("PubNub failed heartbeat")
              else:
                  # Heartbeat operation was successful
                  _LOGGER.info("PubNub heartbeat")
          else:
              pass
docs: Things to do on different status updates.