panoptes.pocs.sensor package¶
Submodules¶
panoptes.pocs.sensor.power module¶
Power board sensor interface for relays and current/voltage readings.
Provides PowerBoard, a serial-connected reader/controller for the PANOPTES power relay board (Arduino + relay shield), and a small Relay data class for labels/states. Includes helpers to toggle relays and to parse/aggregate telemetry into rolling means and status dictionaries.
- class panoptes.pocs.sensor.power.PinState(*values)[source]¶
Bases:
IntEnumRepresents a HIGH or LOW state for a digital output pin.
- HIGH = 1¶
- LOW = 0¶
- OFF = 0¶
- ON = 1¶
- class panoptes.pocs.sensor.power.PowerBoard(port: str = None, name: str = 'Power Board', relays: dict[str, dict] = None, reader_callback: Callable[[dict], dict] = None, mean_interval: int | None = 5, arduino_board_name: str = 'power_board', *args, **kwargs)[source]¶
Bases:
PanBasePower distribution and monitoring.
This represents a “trucker” board for PANOPTES, which is a combination of an Arduino Uno and an Infineon 24V relay shield.
The relay shield has three PROFETs on them that are capable of sensing the current through the relay. RELAY_4 has a dedicated PROFET. The other two PROFETs can switch between two relays depending on the status of the appropriate DSEL pin.
This class uses panoptes.utils.device.serial.SerialDevice for threaded (async) reading of the values from the Arduino Uno connected to the power board, which are parsed by the default callback and appended to a deque whose size can be controlled. A custom callback can be passed that should accept a single string parameter and return a dictionary.
Pin names specified above correspond to Infineon terminology. See manual: https://bit.ly/2IGgWLQ.
- change_relay_state(relay: Relay, new_state_command: TruckerBoardCommands)[source]¶
Changes the relay to the new state.
- default_reader_callback(data)[source]¶
Parse a JSON line from the Arduino into a list for DataFrame append.
- Parameters:
data (str) – JSON string produced by the Arduino firmware, containing keys for relay states and readings along with ac_ok/battery_low.
- Returns:
- A list of values in the order [timestamp, ac_ok, battery_low,
<relay readings…>] suitable for constructing/appending to a pandas DataFrame, or None if the reading is ignored/invalid.
- Return type:
list | None
- classmethod lookup_port(vendor_id=9025, product_id=67, **kwargs)[source]¶
Tries to guess the port hosting the power board arduino.
The default vendor_id is for official Arduino products. The default product_id is for an Uno Rev 3.
https://github.com/arduino/Arduino/blob/1.8.0/hardware/arduino/avr/boards.txt#L51-L58
- property readings¶
Return the rolling mean of the readings.
- record(collection_name: str = None)[source]¶
Record the rolling mean of the power readings in the database.
- Parameters:
collection_name (str) – Where to store the results in the db. If None (the default), then use arduino_board_name.
- property status¶
Summarize relay states and latest readings.
- Returns:
- Mapping of relay name to a dict with label, state, and reading,
plus top-level ‘ac_ok’ and ‘battery_low’ booleans if available.
- Return type:
- class panoptes.pocs.sensor.power.Relay(name: str, relay_index: TruckerRelayIndex, label: str | None, state: PinState | None = PinState.OFF, default_state: PinState | None = PinState.OFF)[source]¶
Bases:
objectRelay data class
- relay_index: TruckerRelayIndex¶
panoptes.pocs.sensor.remote module¶
HTTP-based remote sensor reader for PANOPTES.
Provides RemoteMonitor to poll a JSON endpoint and optionally store the latest reading in the local PANOPTES database.
- class panoptes.pocs.sensor.remote.RemoteMonitor(endpoint_url: str = None, sensor_name: str = None, *args, **kwargs)[source]¶
Bases:
PanBaseDoes a pull request on an endpoint to obtain a JSON document.