Skip to content

Commands, system and timers

Helpers that build the commands sent to devices and to the box. Most users go through TelecoHub and the device classes instead.

commands

Building device commands the way the Daisy app does.

The cloud gives every device its own list of commands (deviceCommandList). The app never hard-codes command ids: a screen asks for an (action, param) pair (e.g. ("OPEN_STOP_CLOSE", "OPEN")) and DaisyApplication#sendCommand picks the matching command from that list. This module is a port of that selection, plus the wire encodings of a command for the cloud (CommandCloud) and for the LAN channel (DaisyApplication#convertForDM).

JsonDict module-attribute

JsonDict = dict[str, Any]

WireCommand dataclass

WireCommand(
    id_installation_device: int,
    device_code: str,
    id_installation_device_command: int,
    command_action: str,
    command_param: str,
    lowlevel_command: str,
    id_devicetype_command_model: int,
    command_index: int = 0,
)

One entry of commandsList (the app's CommandCloud).

id_installation_device instance-attribute

id_installation_device: int

device_code instance-attribute

device_code: str

id_installation_device_command instance-attribute

id_installation_device_command: int

command_action instance-attribute

command_action: str

command_param instance-attribute

command_param: str

lowlevel_command instance-attribute

lowlevel_command: str

id_devicetype_command_model instance-attribute

id_devicetype_command_model: int

command_index class-attribute instance-attribute

command_index: int = 0

command_id property

command_id: int

to_cloud

to_cloud() -> JsonDict

to_wire

to_wire(
    command: Command,
    device: DeviceInfo,
    param: str | None = None,
) -> WireCommand

CommandDao#toCommandCloud.

build_device_command

build_device_command(
    device: DeviceInfo, action: str, param: str
) -> list[WireCommand]

Select and build the command(s) for (action, param) on device.

Port of DaisyApplication#sendCommand (minus the transport choice). Raises TelecoUnsupportedError when the device has no matching command.

build_scenario_commands

build_scenario_commands(
    steps: list[tuple[Command, DeviceInfo, str]],
) -> list[WireCommand]

ScenarioDao#toFeedCommandPost: parametric commands ("0") take the step value.

system_command

system_command(
    box_device_id: int,
    action: str,
    param: str = "",
    *,
    device_code: str = "0",
    lowlevel: str = "",
) -> WireCommand

A box-level command (CommandDao#commandTo*), always commandId 122.

feed_post

feed_post(
    inst_code: str,
    commands: list[WireCommand],
    *,
    scenario_id: int = 0,
    is_scenario: bool | None = None,
) -> JsonDict

Body of tmate20/feedthecommands (without idSession).

is_scenario defaults to scenario_id != 0; the board sync forces it on.

local_payload

local_payload(
    inst_code: str,
    commands: list[WireCommand],
    *,
    scenario_id: int = 0,
) -> str

Compact JSON sent over the LAN (DaisyApplication#convertForDM).

Built by string concatenation exactly like the app (no JSON escaping).

system

Box-level ("system") commands and the scenario string the box stores.

All of them are built like CommandDao#commandTo*: commandId 122 (except the remote pairing commands), target the box device unless noted, and are always sent through the cloud.

BOARD_CODE_NAMES module-attribute

BOARD_CODE_NAMES: dict[int, str] = {
    16: "LMP",
    17: "DIM",
    18: "HEA",
    19: "FAN",
    20: "HEQ",
    21: "PER",
    22: "CAN",
    23: "SER",
    24: "SOL",
    25: "TEN",
    26: "RGB",
    27: "PEG",
    28: "AUD",
    31: "PEQ",
    32: "COP",
    33: "DYP",
    34: "DMS",
    43: "GAK",
    44: "RAS",
    45: "ARS",
    46: "CRP",
    47: "WIN",
}

TX_COMMAND_IDS module-attribute

TX_COMMAND_IDS: dict[str, int] = {
    "PAIR_BUTTON": 108,
    "UNPAIR_BUTTON": 109,
    "PAIR_TX": 127,
    "UNPAIR_TX": 128,
    "RESET_TX": 129,
}

QUERY_ACTIONS module-attribute

QUERY_ACTIONS = (
    "GET_TIME",
    "GET_SIGNAL",
    "GET_VERSION",
    "GET_INFO",
    "GET_DIAGNOSTIC",
)

box_command

box_command(
    box_device_id: int, action: str, param: str = ""
) -> WireCommand

A parameterless-style box command (GET_*, TEST_SCAN, SYNC_BOARD, END_SYNC...).

get_feedback_command

get_feedback_command(device: DeviceInfo) -> WireCommand

Ask the box for a device's feedback (GET_FEEDBACK), targeting the device.

update_device_command

update_device_command(
    device: DeviceInfo, box_device_id: int
) -> WireCommand

Push a device's options to the box (UP_DEV, firmware >= 1.3.3).

update_installation_name_command

update_installation_name_command(
    box_device_id: int, name: str
) -> WireCommand

set_wifi_command

set_wifi_command(
    box_device_id: int, ssid: str, password: str
) -> WireCommand

read_ap_channel_command

read_ap_channel_command(box_device_id: int) -> WireCommand

set_ap_channel_command

set_ap_channel_command(
    box_device_id: int, *, static: bool
) -> WireCommand

Access point channel: static writes 20W, otherwise 06W.

read_memory_command

read_memory_command(
    box_device_id: int, address: str, count: str
) -> WireCommand

set_time_command

set_time_command(
    box_device_id: int, value: str
) -> WireCommand

update_firmware_command

update_firmware_command(
    box_device_id: int, url: str
) -> WireCommand

update_scenario_command

update_scenario_command(
    box_device_id: int, scenario_string: str
) -> WireCommand

delete_scenario_command

delete_scenario_command(
    box_device_id: int, id_scenario: int
) -> WireCommand

tx_command

tx_command(
    action: str, param: str, id_installation_device: int
) -> WireCommand

Remote pairing (CommandDao#commandToTx), sent to the scenario's device.

scenario_string

scenario_string(
    id_scenario: int,
    steps: list[tuple[Command, DeviceInfo, str]],
) -> str

The scenario as stored by the box (ScenarioDao#toScenarioString).

<id>N<count, 2 digits> then, per step, <device index, 2 digits><value> <command model, hex><device id, 8 hex> (no separators inside a step).

timers

Timer helpers: the UP_TIMERS / UP_SCHED / DEL_TIM box commands.

Saving timers is a two-step dance in the app (SetupDeviceTimersActivity): first an UP_TIMERS system command per timer is sent to the box and acked (MessageText == "ACK"), then the device's complete timer list is posted to timer-device-setup/. Deleting one (SetupTimerListActivity#deleteTimer) is the same with DEL_TIM, then the list without that timer.

days_mask

days_mask(days: str) -> int

giorni ("S;S;S;S;S;N;N", Monday first) -> bit mask (Mon=64 ... Sun=1).

up_timers_param

up_timers_param(
    timer: Timer, device: DeviceInfo, command: Command
) -> str

CommandDao#commandToUpdateTimer commandParam.

up_timers_command

up_timers_command(
    box_device_id: int,
    timer: Timer,
    device: DeviceInfo,
    command: Command,
) -> WireCommand

del_timer_command

del_timer_command(
    box_device_id: int, id_timer: int
) -> WireCommand

Remove one timer from the box (DEL_TIM: timer id on 8 hex digits).

up_schedule_command

up_schedule_command(
    box_device_id: int, enabled: bool
) -> WireCommand

Master switch for all the box timers (UP_SCHED).