API Reference¶
- class drok_xyt01.DrokXYT01(config: DrokXYT01Config)¶
Bases:
objectXY-T01 controller driver with asynchronous reader and synchronous acks.
This class manages the serial port, a background reader thread that demultiplexes measurements and command responses, and a simple command API.
Thread safety: one command may be in flight at a time. A dedicated TX lock serializes writes. The reader thread safely hands response lines to the active waiter, if any.
- Parameters:
config – Serial and timing configuration.
- connect(on_measurement: Callable[[str, float], None] | None = None) bool¶
Open the serial port and start the reader thread.
A safe configuration sequence is issued:
stop,off, short delay,startto enable streaming. This is the safe-state sequence.- Parameters:
on_measurement – Optional callback
(mode: str, temp_c: float)that receives asynchronous measurement updates.modeis one of{"CL", "OP", "OFF"}. Must return quickly or risk blocking additional reads.- Returns:
Trueif connected and reader started; otherwiseFalse.
- disconnect() None¶
Stop the reader, close the serial port, and leave the controller OFF.
- enable_logging(verbose: bool = False) None¶
Configure module logging with a simple formatter.
- Parameters:
verbose – If
True, useDEBUGlevel; otherwiseINFO.
- property is_connected: bool¶
Whether the serial port is open.
- Returns:
Trueif the serial device is open.
- off() bool¶
Turn controller output OFF.
- Returns:
Trueon expected ack, elseFalse.
- on() bool¶
Turn controller output ON.
- Returns:
Trueon expected ack, elseFalse.
- query_state() DrokXYT01State¶
Return structured device state.
This issues a
readand parses the result into aDrokXYT01State.- Returns:
Parsed
DrokXYT01State.
- read_settings() tuple[str, str, str]¶
Read the three settings/state lines from the controller.
- Returns:
Tuple of three raw lines (L1, L2, L3). Empty strings on timeout.
- reset() None¶
Reset the controller and reconnect.
The sequence is:
stop,off, wait ~2 s, clear buffers, disconnect, connect. The existing measurement callback is preserved.
- set_alarm(temp_c: float) bool¶
Set the controller alarm threshold.
- Parameters:
temp_c – Alarm in °C (
-50..110).- Returns:
Trueif an expected state (DOWNorUP) is received.
- set_setpoint(temp_c: float) bool¶
Set the controller setpoint.
- Parameters:
temp_c – Setpoint in °C (
-50..110).- Returns:
Trueon expected ack, elseFalse.
- start() bool¶
Start streaming measurements.
- Returns:
Trueon expected ack, elseFalse.
- stop() bool¶
Stop streaming measurements.
- Returns:
Trueon expected ack, elseFalse.
- drok_xyt01.DrokXYT01Cli() None¶
Simple CLI for manual interaction and demonstration.
- class drok_xyt01.DrokXYT01Config(port: str = '/dev/serial1', baudrate: int = 9600, read_timeout_s: float = 2.0, write_timeout_s: float = 1.0, crlf: str = '\n', ack_timeout_s: float = 3.0, txrx_delay_s: float = 1.0)¶
Bases:
objectSerial and timing configuration for
DrokXYT01.- Parameters:
port – Serial device path.
baudrate – UART baud rate.
read_timeout_s – Serial
readlinetimeout (seconds).write_timeout_s – Serial write timeout (seconds).
crlf – Line terminator appended to transmitted commands.
ack_timeout_s – Maximum time to wait for a command’s response lines.
txrx_delay_s – Inter-command delay between TX and the first RX wait.
- ack_timeout_s: float = 3.0¶
- baudrate: int = 9600¶
- crlf: str = '\n'¶
- port: str = '/dev/serial1'¶
- read_timeout_s: float = 2.0¶
- txrx_delay_s: float = 1.0¶
- write_timeout_s: float = 1.0¶
- class drok_xyt01.DrokXYT01State(mode: str | None, setpoint_c: float | None, hysteresis_c: float | None, alarm_c: float | None, start_delay_min: int | None, calibration_bias_c: float | None)¶
Bases:
objectStructured state returned by
DrokXYT01.query_state().- Variables:
mode –
"heat"or"cool"(derived from H/C), orNoneif unknown.setpoint_c – Setpoint temperature in °C, if available.
hysteresis_c – Hysteresis in °C, if available.
alarm_c – Alarm threshold in °C, if available.
start_delay_min – Output start delay (
OPH) in minutes, if available.calibration_bias_c – Calibration offset (
OFE) in °C, if available.
- alarm_c: float | None¶
- calibration_bias_c: float | None¶
- hysteresis_c: float | None¶
- mode: str | None¶
- setpoint_c: float | None¶
- start_delay_min: int | None¶