def packet_events(packet: dict) -> Generator:
field_abbrev = {v: k for k, v in PACKET_FIELDS.items()}<EOL>packet_id = serialize_packet_id(packet)<EOL>events = {f: v for f, v in packet.items() if f in field_abbrev}<EOL>if '<STR_LIT>' in events or '<STR_LIT:version>' in events:<EOL><INDENT>yield dict(id=packet_id, **events)<EOL><DEDENT>else:<EOL><INDENT>if packet_id == '<STR_LIT>':<EOL><INDENT>yield {<EOL>'<STR_LIT:id>': '<STR_LIT>',<EOL>'<STR_LIT:value>': packet.get('<STR_LIT>'),<EOL>'<STR_LIT>': packet.get('<STR_LIT>'),<EOL>'<STR_LIT>': packet.get('<STR_LIT>'),<EOL>}<EOL><DEDENT>else:<EOL><INDENT>for sensor, value in events.items():<EOL><INDENT>unit = packet.get(sensor + '<STR_LIT>', None)<EOL>yield {<EOL>'<STR_LIT:id>': packet_id + PACKET_ID_SEP + field_abbrev[sensor],<EOL>'<STR_LIT>': sensor,<EOL>'<STR_LIT:value>': value,<EOL>'<STR_LIT>': unit,<EOL>}<EOL><DEDENT>if packet_id != '<STR_LIT>':<EOL><INDENT>yield {<EOL>'<STR_LIT:id>': packet_id + PACKET_ID_SEP + '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:value>': round(time.time()),<EOL>'<STR_LIT>': '<STR_LIT:s>',<EOL>}<EOL><DEDENT><DEDENT><DEDENT>
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