docs: def packet_events(packet: dict) -> Generator:
      """Return list of all events in the packet.
  
      >>> x = list(packet_events({
      ...     'protocol': 'alecto v1',
      ...     'id': 'ec02',
      ...     'temperature': 1.0,
      ...     'temperature_unit': '°C',
      ...     'humidity': 10,
      ...     'humidity_unit': '%',
      ... }))
      >>> assert {
      ...     'id': 'alectov1_ec02_temp',
      ...     'sensor': 'temperature',
      ...     'value': 1.0,
      ...     'unit': '°C',
      ... } in x
      >>> assert {
      ...     'id': 'alectov1_ec02_hum',
      ...     'sensor': 'humidity',
      ...     'value': 10,
      ...     'unit': '%',
      ... } in x
      >>> y = list(packet_events({
      ...     'protocol': 'newkaku',
      ...     'id': '000001',
      ...     'switch': '01',
      ...     'command': 'on',
      ... }))
      >>> assert {'id': 'newkaku_000001_01', 'command': 'on'} in y
      """
      field_abbrev = {v: k for k, v in PACKET_FIELDS.items()}
  
      packet_id = serialize_packet_id(packet)
      events = {f: v for f, v in packet.items() if f in field_abbrev}
      if 'command' in events or 'version' in events:
          # switch events only have one event in each packet
          yield dict(id=packet_id, **events)
      else:
          if packet_id == 'debug':
              yield {
                  'id': 'raw',
                  'value': packet.get('pulses(usec)'),
                  'tm': packet.get('tm'),
                  'pulses': packet.get('pulses'),
              }
          else:
              # sensors can have multiple
              for sensor, value in events.items():
                  unit = packet.get(sensor + '_unit', None)
                  yield {
                      'id': packet_id + PACKET_ID_SEP + field_abbrev[sensor],
                      'sensor': sensor,
                      'value': value,
                      'unit': unit,
                  }
  
              if packet_id != 'rflink':
                  yield {
                     'id': packet_id + PACKET_ID_SEP + 'update_time',
                     'sensor': 'update_time',
                     'value': round(time.time()),
                     'unit': 's',
                  }