code: async def from_payload(cls, payload, endpoint, idgen, debug, force_protocol=None):
          
          service_name = payload["service"]
  
          if "protocols" not in payload:
              raise SongpalException(
                  "Unable to find protocols from payload: %s" % payload
              )
  
          protocols = payload["protocols"]
          _LOGGER.debug("Available protocols for %s: %s", service_name, protocols)
          if force_protocol and force_protocol.value in protocols:
              protocol = force_protocol
          elif "websocket:jsonizer" in protocols:
              protocol = ProtocolType.WebSocket
          elif "xhrpost:jsonizer" in protocols:
              protocol = ProtocolType.XHRPost
          else:
              raise SongpalException(
                  "No known protocols for %s, got: %s" % (service_name, protocols)
              )
          _LOGGER.debug("Using protocol: %s" % protocol)
  
          service_endpoint = "%s/%s" % (endpoint, service_name)
  
          # creation here we want to pass the created service class to methods.
          service = cls(service_name, service_endpoint, protocol, idgen, debug)
  
          sigs = await cls.fetch_signatures(
              service_endpoint, protocol, idgen
          )
  
          if debug > 1:
              _LOGGER.debug("Signatures: %s", sigs)
          if "error" in sigs:
              _LOGGER.error("Got error when fetching sigs: %s", sigs["error"])
              return None
  
          methods = {}
  
          for sig in sigs["results"]:
              name = sig[0]
              parsed_sig = MethodSignature.from_payload(*sig)
              if name in methods:
                  _LOGGER.debug("Got duplicate signature for %s, existing was %s. Keeping the existing one",
                                parsed_sig, methods[name])
              else:
                  methods[name] = Method(service, parsed_sig, debug)
  
          service.methods = methods
  
          if "notifications" in payload and "switchNotifications" in methods:
              notifications = [
                  Notification(
                      service_endpoint, methods["switchNotifications"], notification
                  )
                  for notification in payload["notifications"]
              ]
              service.notifications = notifications
              _LOGGER.debug("Got notifications: %s" % notifications)
  
          return service
docs: Create Service object from a payload.