Skip to main content

system.mes.oee.setDowntimeReasonForStateRecord

Description

Sets a downtime reason for a specific OEE state record, with optional notes and an acknowledgment status.

Permissions

This method requires the OEE.WRITE.SAVE permission.

Syntax

system.mes.oee.setDowntimeReasonForStateRecord(oeeStateRecordId, downtimeReasonId=None, notes=None, acknowledge=False)

Parameters

ParameterTypeNullableDescription
oeeStateRecordIdStringFalseThe ID of the OEE state record to update.
downtimeReasonIdStringTrueThe ID of the downtime reason to assign. Set to None to clear.
notesStringTrueOptional notes to add to the state record.
acknowledgeBooleanTrueWhether to acknowledge the record. Defaults to False.

Returns

A JSON representation of the updated OeeStateRecordDTO object.

NameTypeNullableDescriptionDefault Value
idStringTrueThe id of the OEE State Recordnull
codeIntegerFalseInteger state numbernull
locationIdStringFalseIdentifier of the associated location where this state record was recordednull
locationNameStringTrueName of the associated locationnull
locationPathStringTruePath of the location where this state record was recordednull
nameStringFalseName of the recorded statenull
calculationTypeOeeStateCalculationTypeFalseSpecifies how this state contributes to OEE calculationsDOWNTIME
colorStringFalseHex color code representing the state visually"#000000"
statusStatusFalseStatus of the OEE record (e.g., running, faulted, canceled, complete)UNKNOWN
startDateInstantFalseStart date and time of the state recordInstant.now()
endDateInstantTrueEnd date and time of the state recordnull
durationDoubleFalseDuration of the state record in seconds0.0
downtimeReasonIdStringTrueIdentifier of the associated downtime reason, if applicablenull
downtimeReasonStringTrueTitle of the downtime reason. (Name - Code) For display purposes onlynull
downtimeReasonPathStringTruePath to the current downtime reasonnull
interruptionLocationIdStringTrueLocation id that caused the blocked/starved state on the machinenull
interruptionLocationNameStringTrueName of the interruption location that caused the blocked/starved statenull
interruptionLocationPathStringTrueLocation path that caused the blocked/starved state on the machinenull
acknowledgedBooleanFalseBoolean indicating whether the state record has been acknowledgedfalse
acknowledgedByStringTrueAcknowledged By. This is the user who acknowledged the state recordnull
acknowledgedDateInstantTrueAcknowledged Date. This is the date when the state record was acknowledgednull
modeRecordIdStringTrueIdentifier of the associated mode recordnull
rootCauseStateRecordIdStringTrueIdentifier of the root cause state record, if applicablenull
primaryAlarmRecordIdStringTrueIdentifier of the associated OEE Alarm Record, if applicablenull
primaryAlarmNameStringTruePrimary alarm name, if applicablenull
primaryAlarmDisplayPathStringTruePrimary alarm display path, if applicablenull
primaryAlarmLabelStringTruePrimary alarm display name, if applicablenull
notesStringTrueNotes associated with the OEE State Recordnull
enabledbooleanTrueIndicates whether the OEE State Record is enabledtrue
spare1StringTrueExtra field 1null
spare2StringTrueExtra field 2null
spare3StringTrueExtra field 3null

Code Examples

# Assume we have a state record ID and a reason ID
stateRecordId = "someStateRecordId"
reasonId = "some-downtime-reason-id"

# Set the downtime reason and add a note
try:
updatedRecord = system.mes.oee.setDowntimeReasonForStateRecord(
oeeStateRecordId=stateRecordId,
downtimeReasonId=reasonId,
notes="Operator confirmed mechanical jam.",
acknowledge=True
)
print "Successfully updated state record:", updatedRecord['id']
print "New Reason:", updatedRecord['downtimeReason']
print "Acknowledged:", updatedRecord['acknowledged']

except Exception as e:
print "Error updating state record:", str(e)

# To clear a downtime reason
# system.mes.oee.setDowntimeReasonForStateRecord(stateRecordId, None, "Reason cleared.")