Skip to content

naneos.protobuf

The protobuf schema of the naneos IoT service and the DataFrame -> protobuf conversion.

create_proto_device(sn, abs_time, df)

One Device message from a frame indexed by unix seconds.

Source code in src/naneos/protobuf/protobuf.py
123
124
125
126
127
128
129
130
131
132
def create_proto_device(sn: int, abs_time: int, df: pd.DataFrame) -> pb.Device:
    """One Device message from a frame indexed by unix seconds."""
    device = pb.Device()
    device.type = int(device_type_of(df))  # type: ignore[assignment]  # same numbers as pb.DeviceType
    device.serial_number = sn

    device_points = [_create_device_point(row, abs_time) for _, row in df.iterrows()]
    device.device_points.extend(point for point in device_points if point is not None)

    return device