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’send
value must be set tonull
. This means downtime blocks with bothend
andauto_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 0x79d314f5dd80>]]
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 or0
to get only unplanned downtime blockmachine (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:
201 Created – on success
404 Not Found – if the machine does not exist
- 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:
404 Not Found – if the downtime ID is invalid
- PATCH /api/downtime/(int: downtime_id)
Edit a downtime block.
- Parameters:
downtime_id – the ID of the downtime block
- Status Codes:
404 Not Found – if the downtime ID is invalid
- 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:
404 Not Found – if the downtime ID is invalid
204 No Content – on success
- 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:
201 Created – if the creation is successful
400 Bad Request – if the
name
field is missing
- Returns:
the new category object
- PATCH /api/downtime/categories/(int: category_id)
Edit an existing downtime category.
- Status Codes:
404 Not Found – if the category does not exist
- DELETE /api/downtime/categories/(int: category_id)
Delete an existing downtime category.
- Status Codes:
404 Not Found – if the category does not exist
204 No Content – on success