Skip to main content

History

ua.read_history(...) This simplifies the entry point; the complete version is directly API attached OpcUaSession to, and is named read_history_* / update_history / delete_history_*.

Subpage Redirect

5 Modes HistoryRead​

PatternAPINote
Raw Dataread_historyAll points within the interval
Modified (includes revision history)read_history_modifiedThe range contains modification records
AtTime A specific point in timeread_history_at_timeInterpolation for a Given Timestamp
Processed Aggregationread_history_processedAggregation (Avg / Min / Max / ...)
Events Historyread_history_eventsHistorical Events (Alarms / Conditions)

HistoryUpdate​

APIUses
update_historyInsert / Replace / Update / Remove Historical Data
delete_history_rangeDelete History by Time Period

Timestamp Convention​

All input parameters API and return values are datetime UTC:

import datetime as dt

start = dt.datetime.now(dt.timezone.utc) - dt.timedelta(hours=1)
end = dt.datetime.now(dt.timezone.utc)

Do not transmit the local time (dt.datetime.now() default is local, no tzinfo). Internal SDK datetime → FILETIME conversions will force the processing UTC of naive times datetime.

General Prerequisites​

  • The server must support Historian; otherwise OpcUaException, it throws an exception with status code StatusCode.BadHistoryOperationUnsupported (the secure version does read_history_safe not throw an exception; it returns (StatusCode, [])).
  • AccessLevel The HistoryRead bit (bit 2 / 0x04) and the bit HistoryWrite (bit 3 / 0x08) of the node must be set.
  • The "Historizing Attribute" (20) node determines whether to record history.
  • All historical methods areSynchronize, RPC Returns control to the calling thread; method-levelNo cancellation / timeout parameters (Constrained request_timeout_ms RPC by session-based parameters each time; default 5000 ms), large intervals can only be sliced on the business side

Companion entry points​

  • ua.read_history_safe(...) — read_history Safe version, exception handling (StatusCode, []), no exception thrown
  • read_history_stream — Stream reading — Asynchronous generators yield items one by one to prevent the list from overflowing and causing a memory crash

Next Step​