fastiot.msg.thing module

pydantic model fastiot.msg.thing.Thing[source]

Default data model for sending Things (e.g. Sensors) values.

This model expects a hierarchy, thus when subscribing always set the name to the sensor name you are looking for or to * to subscribe all sensors. See fastiot.core.data_models.FastIoTData.get_subject() for more details!.

field machine: str [Required]

Name of the machine. If you have many machines you may add the vendor to the machine name.

Validated by:
field name: str [Required]

Name of the thing or sensor.

Validated by:
field measurement_id: str = '626a03a2-bda4-11ed-beb1-0242ac110002'

Measurement id for this thing or sensor. The measurement id is intended to be unique across a measurement. If the data producer is restarted, it should change. This can be useful e.g. if a measurement is messed up and needs to be removed. Per default a UUID will be generated upon system start for this property.

Validated by:
field value: Any = None

Any data type suitable for Pydantic and serializable by ormsgpack may be used. Be aware, that the receiving site needs no be able to cope with whatever you send.

We recommend to stick to int, float and string and create your own data models based on fastiot.core.subject.FastIoTData if want to sent more advanced data.

Validated by:
field timestamp: datetime [Required]

Timestamp for the value.

It is recommended to always use UTC times (Function datetime.utcnow()).

Validated by:
field unit: str = ''

Optional add a unit, e.g. ‘s’ to the measurement.

Validated by:
property default_subject: Subject

Returns a default subject for this thing to be published on. For more fine-grained behavior, please consider using get_subject instead.