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).
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).
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.
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
¶
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_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
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
¶
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
¶
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).