OzWrapper.OzAnomaly.data_provider.OzCacheProvider

class OzWrapper.OzAnomaly.data_provider.OzCacheProvider(cache: OzCache | None)

Bases: DataProvider

digraph inheritancef363e48165 { bgcolor=transparent; rankdir=TB; ratio=compress; size="8.0, 6.0"; "ABC" [URL="https://docs.python.org/3/library/abc.html#abc.ABC",fillcolor="#e8f4f8",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="filled,rounded",target="_top",tooltip="Helper class that provides a standard way to create an ABC using"]; "DataProvider" [URL="DataProvider.html#OzWrapper.OzAnomaly.data_provider.DataProvider",fillcolor="#e8f4f8",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="filled,rounded",target="_top",tooltip="Supplies recent sensor data to the anomaly detector."]; "ABC" -> "DataProvider" [arrowhead=empty,arrowsize=0.8,style="setlinewidth(0.5)"]; "OzCacheProvider" [URL="OzCacheProvider.html#OzWrapper.OzAnomaly.data_provider.OzCacheProvider",fillcolor="#e8f4f8",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="filled,rounded",target="_top",tooltip="Read recent sensor payloads from the Manager-owned :class:`OzCache`."]; "DataProvider" -> "OzCacheProvider" [arrowhead=empty,arrowsize=0.8,style="setlinewidth(0.5)"]; }

Read recent sensor payloads from the Manager-owned OzCache.

OzCache is a Redis-backed rolling list of the same data dicts that Manager.sendData publishes to the gateway. The cache is populated by two paths:

  1. Live ticks — every successful publish writes its payload to Redis (Manager.sendData calls self.cache.push(payload) before the HTTP POST).

  2. Cold-start refillOzCache.refill() paginates through the gateway’s /ppb/device/ endpoint at boot to seed the cache before live ticks have caught up.

OzCache normalises every payload’s t field to milliseconds — live ticks are already ms (lastPublishMillis), and refilled PPB rows (which arrive in seconds) are multiplied by 1000 inside OzCache.refill. So this provider can apply a single ms-based cutoff without inspecting where each row came from.

Args: cache: The OzCache instance owned by Manager (typically

manager.cache). May be None or unconfigured — get_window() handles both and returns None.

get_window(hours: int) Window | None

Return the last hours of cached payloads as a column dict.

Returns None when the cache is unavailable, empty, or holds no records inside the requested window.

__slots__ = ()
cache