Skip to content

CLI Commands Reference

This page documents all available commands for the pydoover CLI, organized by interface.

Platform Interface Commands

Commands for interacting with the Platform Interface container. Access device I/O and system information.

test_comms

Test connection by sending a basic echo response to the platform interface container.

pydoover platform test_comms [--message MESSAGE]

Options:

OptionTypeDefaultDescription
--messagestr"Comms Check Message"Message to send for echo response

Example:

pydoover platform test_comms --message "Hello Platform"

get_di

Get digital input values.

pydoover platform get_di <pin>

Arguments:

ArgumentTypeDescription
pinintDigital input pin number

Example:

# Get digital input pin 0
pydoover platform get_di 0

# Get digital input pin 3
pydoover platform get_di 3

get_ai

Get analog input values.

pydoover platform get_ai <pin>

Arguments:

ArgumentTypeDescription
pinintAnalog input pin number

Example:

# Get analog input pin 0
pydoover platform get_ai 0

get_do

Get digital output values.

pydoover platform get_do <pin>

Arguments:

ArgumentTypeDescription
pinintDigital output pin number

Example:

pydoover platform get_do 0

set_do

Set digital output values.

pydoover platform set_do <do> <value>

Arguments:

ArgumentTypeDescription
doint or listDigital output pin number(s)
valueint or listValue(s) to set (0 or 1)

Examples:

# Set digital output pin 1 to high
pydoover platform set_do 1 1

# Set digital output pin 2 to low
pydoover platform set_do 2 0

schedule_do

Schedule digital output values to change after a delay.

pydoover platform schedule_do <do> <value> <in_secs>

Arguments:

ArgumentTypeDescription
doint or listDigital output pin number(s)
valuebool or listValue(s) to set
in_secsintSeconds until the change takes effect

Example:

# Set digital output pin 1 to high in 10 seconds
pydoover platform schedule_do 1 1 10

get_ao

Get analog output values.

pydoover platform get_ao <pin>

Arguments:

ArgumentTypeDescription
pinintAnalog output pin number

Example:

pydoover platform get_ao 0

set_ao

Set analog output values.

pydoover platform set_ao <ao> <value>

Arguments:

ArgumentTypeDescription
aoint or listAnalog output pin number(s)
valuefloat or listValue(s) to set

Examples:

# Set analog output pin 1 to 3.3V
pydoover platform set_ao 1 3.3

# Set analog output pin 2 to 1.5V
pydoover platform set_ao 2 1.5

schedule_ao

Schedule analog output values to change after a delay.

pydoover platform schedule_ao <ao> <value> <in_secs>

Arguments:

ArgumentTypeDescription
aoint or listAnalog output pin number(s)
valuefloat or listValue(s) to set
in_secsintSeconds until the change takes effect

Example:

# Set analog output pin 1 to 2.5V in 5 seconds
pydoover platform schedule_ao 1 2.5 5

get_system_voltage

Get the system input voltage.

pydoover platform get_system_voltage

Returns: System input voltage in volts.

get_system_power

Get the system input power.

pydoover platform get_system_power

Returns: System input power in watts.

get_system_temperature

Get the system temperature (e.g., Raspberry Pi CM4 temperature on Doovit).

pydoover platform get_system_temperature

Returns: System temperature in degrees Celsius.

get_location

Get the device location (typically via ModemManager on 4G-enabled devices).

pydoover platform get_location

Returns: Location object with latitude, longitude, and altitude.

reboot

Reboot the device.

pydoover platform reboot

Warning: This will immediately reboot the device. Use with caution.

shutdown

Shutdown the device.

pydoover platform shutdown

Warning: This will immediately shut down the device. Use with caution.

get_immunity_seconds

Get the number of seconds the device is immune from shutdown requests.

pydoover platform get_immunity_seconds

Returns: Immunity time in seconds.

set_immunity_seconds

Set the number of seconds the device is immune from shutdown requests.

pydoover platform set_immunity_seconds <immunity_secs>

Arguments:

ArgumentTypeDescription
immunity_secsintImmunity duration in seconds

Example:

# Set 120 seconds of shutdown immunity
pydoover platform set_immunity_seconds 120

schedule_shutdown

Schedule a shutdown to occur after a delay.

pydoover platform schedule_shutdown <time_secs>

Arguments:

ArgumentTypeDescription
time_secsintSeconds until shutdown

get_io_table

Get the I/O table configuration.

pydoover platform get_io_table

Returns: JSON representation of the I/O table.

sync_rtc

Synchronize the real-time clock (RTC) with the system (network) time.

pydoover platform sync_rtc

get_di_events

Get digital input events for a specific pin.

pydoover platform get_di_events <di_pin> <edge> [--include_system_events] [--events_from TIMESTAMP]

Arguments:

ArgumentTypeDescription
di_pinintDigital input pin number
edgestrEdge type: "rising", "falling", or "both"

Options:

OptionTypeDefaultDescription
--include_system_eventsboolFalseInclude system events
--events_fromint0Starting event ID or timestamp (milliseconds)

Device Agent Interface Commands

Commands for interacting with the Device Agent container. Manage channels and cloud connectivity.

test_comms

Test connection by sending a basic echo response to the device agent container.

pydoover device_agent test_comms [--message MESSAGE]

Options:

OptionTypeDefaultDescription
--messagestr"Comms Check Message"Message to send for echo response

get_is_dda_available

Check if the Device Agent service is available.

pydoover device_agent get_is_dda_available

Returns: Boolean indicating availability.

get_is_dda_online

Check if the Device Agent service is currently online.

pydoover device_agent get_is_dda_online

Returns: Boolean indicating online status.

get_has_dda_been_online

Check if the Device Agent service has been online at least once since startup.

pydoover device_agent get_has_dda_been_online

Returns: Boolean.

await_dda_available

Wait for the Device Agent to become available.

pydoover device_agent await_dda_available [--timeout SECONDS]

Options:

OptionTypeDefaultDescription
--timeoutint10Maximum seconds to wait

get_channel_aggregate

Fetch a channel's current aggregate payload.

pydoover device_agent get_channel_aggregate <channel_name>

Arguments:

ArgumentTypeDescription
channel_namestrName of the channel

Example:

pydoover device_agent get_channel_aggregate my_channel

Returns: Channel aggregate data as JSON or string.

publish_to_channel

Publish a message to a channel.

pydoover device_agent publish_to_channel <channel_name> <message> [--record_log] [--max_age SECONDS]

Arguments:

ArgumentTypeDescription
channel_namestrName of the channel
messagedict or strMessage payload (JSON or string)

Options:

OptionTypeDefaultDescription
--record_logboolTrueWhether to save to log
--max_ageintNoneMaximum age before publishing to cloud (-1 for immediate)

Example:

pydoover device_agent publish_to_channel my_channel '{"foo": "bar"}'

get_temp_token

Get a temporary API token.

pydoover device_agent get_temp_token

Returns: Tuple of (token, expiry_time, endpoint).

Note: This is deprecated. WSS tokens are now valid for API calls.

listen_channel

Listen to a channel and print updates to the console.

pydoover device_agent listen_channel <channel_name>

Arguments:

ArgumentTypeDescription
channel_namestrName of the channel to listen to

Example:

pydoover device_agent listen_channel my_channel

This command runs continuously, printing channel updates as they arrive. Press Ctrl+C to stop.


Modbus Interface Commands

Commands for interacting with the Modbus Interface container. Manage modbus buses and registers.

test_comms

Test connection by sending a basic echo response to the modbus interface container.

pydoover modbus test_comms [--message MESSAGE]

Options:

OptionTypeDefaultDescription
--messagestr"Comms Check Message"Message to send for echo response

open_bus

Open a modbus bus connection.

pydoover modbus open_bus [options]

Options:

OptionTypeDefaultDescription
--bus_typestr"serial"Bus type: "serial" or "tcp"
--namestr"default"Bus identifier name
--serial_portstr"/dev/ttyS0"Serial port path
--serial_baudint9600Serial baud rate
--serial_methodstr"rtu"Modbus method
--serial_bitsint8Data bits
--serial_paritystr"N"Parity: "N", "E", or "O"
--serial_stopint1Stop bits
--serial_timeoutfloat0.3Serial timeout in seconds
--tcp_uristr"127.0.0.1:5000"TCP address for TCP bus
--tcp_timeoutint2TCP timeout in seconds

Examples:

# Open a serial RTU bus
pydoover modbus open_bus --bus_type serial --name my_bus --serial_port /dev/ttyUSB0 --serial_baud 19200

# Open a TCP modbus bus
pydoover modbus open_bus --bus_type tcp --name tcp_bus --tcp_uri 192.168.1.100:502

close_bus

Close a modbus bus connection.

pydoover modbus close_bus [--bus_id BUS_ID]

Options:

OptionTypeDefaultDescription
--bus_idstr"default"Bus identifier to close

Example:

pydoover modbus close_bus --bus_id my_bus

get_bus_status

Get the status of a modbus bus.

pydoover modbus get_bus_status [--bus_id BUS_ID]

Options:

OptionTypeDefaultDescription
--bus_idstr"default"Bus identifier

Returns: Boolean indicating if the bus is open.

read_registers

Read registers from a modbus device.

pydoover modbus read_registers [options]

Options:

OptionTypeDefaultDescription
--bus_idstr"default"Bus identifier
--modbus_idint1Modbus device ID
--start_addressint0Starting register address
--num_registersint1Number of registers to read
--register_typeint4Register type (4 = holding registers)
--configure_busboolTrueAuto-configure bus if unavailable

Examples:

# Read 10 holding registers starting at address 0
pydoover modbus read_registers --bus_id my_bus --modbus_id 1 --start_address 0 --num_registers 10

# Read input registers (type 3)
pydoover modbus read_registers --modbus_id 2 --start_address 100 --num_registers 5 --register_type 3

Returns: Integer value (single register) or list of integers (multiple registers).

write_registers

Write values to registers on a modbus device.

pydoover modbus write_registers [options]

Options:

OptionTypeDefaultDescription
--bus_idstr"default"Bus identifier
--modbus_idint1Modbus device ID
--start_addressint0Starting register address
--valueslist[int]NoneRegister values to write
--register_typeint4Register type (4 = holding registers)
--configure_busboolTrueAuto-configure bus if unavailable

Example:

# Write values to holding registers
pydoover modbus write_registers --bus_id my_bus --modbus_id 1 --start_address 0 --values "[100, 200, 300]"

Returns: Boolean indicating success.


Command Decorators

The CLI uses decorators to register methods as CLI commands.

@command Decorator

The @command decorator from pydoover.cli.decorators marks a method as a CLI command:

from pydoover.cli.decorators import command as cli_command

@cli_command(name="custom_name", description="Custom description", setup_api=False)
def my_method(self, arg1: str, arg2: int = 10):
    """Method docstring used if no description provided."""
    pass

Parameters:

ParameterTypeDefaultDescription
namestrNoneCustom command name (defaults to method name)
descriptionstrNoneCommand description (defaults to docstring)
setup_apiboolFalseWhether to set up API before running

@annotate_arg Decorator

Add custom descriptions to arguments:

from pydoover.cli.decorators import annotate_arg

@cli_command()
@annotate_arg("pin", "The GPIO pin number to read")
def read_pin(self, pin: int):
    pass

@ignore_alias Decorator

Prevent a method from being registered as a CLI command:

from pydoover.cli.decorators import ignore_alias

@ignore_alias
def internal_method(self):
    """This method will not be available via CLI."""
    pass

Type Parsing

The CLI supports special type parsing for complex argument types:

Python TypeCLI Input FormatExample
intInteger42
floatDecimal3.14
strString"hello"
boolBooleanTrue or False
list[int]JSON array"[1, 2, 3]"
list[bool]JSON array"[true, false]"
list[float]JSON array"[1.0, 2.5]"
dict or strJSON or string'{"key": "value"}'

BoolFlag Type

For boolean flags that toggle behavior:

from pydoover.cli.parsers import BoolFlag

def my_command(self, verbose: BoolFlag = False):
    pass

This creates a --verbose flag that toggles the default value.