Downtime

Model

class pytm4srv.models.Downtime
alarm_id: Mapped[int | None]

ID of the alarm that directly caused this downtime, if any.

auto_end: Mapped[str | None]

When to automatically end this downtime.

  • null: never (default)

  • "ACTIVE": End when the machine changes to an active state.

  • "PART": End when the machine produces a part. The cycle time will be subtracted.

For auto-end to set the end timestamp of a downtime block, the block’s end value must be set to null. This means downtime blocks with both end and auto_end non-null will never automatically end.

classmethod auto_end_active(machine_id: int)

End downtime blocks on the given machine that are waiting for the machine to become active.

The end timestamp of each block will be set to the current time.

classmethod auto_end_part(machine_id: int, cycle_length: timedelta)

End downtime blocks on the given machine that are waiting for a part to be finished.

The end timestamp of each block will be set to the current time minus the cycle length.

Parameters:
  • machine_id – the ID of the machine to end downtime on

  • cycle_length – the length of the part’s cycle

category_id: Mapped[int | None]

The ID of the category/reason for this downtime. References a user-defined DowntimeCategory object.

end: Mapped[datetime | None]

The date and time this downtime stopped.

null means the downtime is still ongoing.

id: MappedColumn object at 0x79cdb3d75c60>]]

Unique, numeric ID of this downtime block.

issue_id: Mapped[int | None]

The ID of the issue that caused this downtime, if any.

Usually for unplanned downtime.

machine_id: Mapped[int]

The ID of the machine that was down.

maintenance_item_id: Mapped[int | None]

The ID of the maintenance item that was being performed during this downtime, if any.

Usually for planned downtime.

notes: Mapped[str]

User-specified notes about this downtime.

planned: Mapped[bool]

Whether this downtime was planned (true) or unplanned (false).

reporter_id: Mapped[int | None]

The ID of the user who reported this downtime.

Will be null if the downtime was created automatically.

start: Mapped[datetime]

The date and time this downtime started.

value: Mapped[float | None]

The currency value of production lost during this downtime.

This field may be NULL for downtime that has not yet ended. When downtime ends automatically, this field will only be modified if it is NULL.

Endpoints

GET /api/downtime/

Search for existing downtime blocks.

Query Parameters:
  • start (int) – set to a UNIX timestamp to get downtime blocks starting or ending at or after that timestamp

  • end (int) – set to a UNIX timestamp to get downtime blocks starting or ending at or before that timestamp

  • planned (int) – set to 1 to get only planned downtime blocks or 0 to get only unplanned downtime block

  • machine (int) – if provided, only downtime blocks on the machine with this ID will be returned. Can be provided multiple times to include downtime blocks from multiple machines.

  • category (int) – if provided, only downtime blocks with this category will be returned. Can be provided multiple times to include downtime blocks from multiple categories. Use 0 to get downtime blocks without a category set.

  • user (int) – set to the ID of a user to get only downtime blocks reported by that user. Can be provided multiple times to include downtime blocks from multiple users. Use 0 to get downtime blocks that were created automatically.

  • alarm (int) – set to the ID of an alarm to get only downtime blocks associated with it. Use 0 to get only downtime blocks that are not associated with an alarm.

  • issue (int) – set to the ID of an issue to get only downtime blocks associated with it. Use 0 to get only downtime blocks that are not associated with an issue.

  • maintenance_item (int) – set to the ID of a maintenance item to get only downtime blocks associated with it. Use 0 to get only downtime blocks that are not associated with a maintenance item.

Returns:

an object mapping downtime block ID to downtime block object

PUT /api/downtime/(int: machine_id)

Report downtime on a machine.

Parameters:
  • machine_id – the ID of the machine to create a downtime block for

Status Codes:
Reqjson:

a Downtime object (can be partial, but at least start is required)

Returns:

the newly created Downtime object

GET /api/downtime/(int: downtime_id)

Get a single downtime block.

Parameters:
  • downtime_id – the ID of the downtime block

Status Codes:
PATCH /api/downtime/(int: downtime_id)

Edit a downtime block.

Parameters:
  • downtime_id – the ID of the downtime block

Status Codes:
Reqjson:

a (partial) Downtime object

Returns:

the entire modified downtime block

DELETE /api/downtime/(int: downtime_id)

Delete a downtime block.

Parameters:
  • downtime_id – the ID of the downtime block

Status Codes:
GET /api/downtime/categories

Get all user-defined downtime categories.

Returns:

an object mapping category ID to category object

PUT /api/downtime/categories

Create a new downtime category.

Status Codes:
Returns:

the new category object

PATCH /api/downtime/categories/(int: category_id)

Edit an existing downtime category.

Status Codes:
DELETE /api/downtime/categories/(int: category_id)

Delete an existing downtime category.

Status Codes: