Device command subscribe

From Sim Innovations Wiki
Jump to navigation Jump to search


device_command_subscribe(cmd_name, callback)
device_command_subscribe(device_id, cmd_name, callback)

device_cmd_subscribe is used to subscribe to a command for a device. Available commands depends on the device type. A callback is called when the property changes value.

See Device list for available commands.

Return value

This function won't return a value.


# Argument Type Description
1 device_id id (Optional) Device id. This can be obtained through Device_add function. Not needed when starting script within Device plugin.
2 cmd_name String Command name which need to be set. See the Device list for available commands.
3 callback function Function that is called when command is fired.


-- Subscribe to property
device_command_subscribe("CMD_NAME", function()
  print("command fired")