|
| 1 | +--- |
| 2 | +name: dev-workflow |
| 3 | +description: Setting up the development environment, deploying Edge Drivers to hubs, and sharing drivers with other users via channels and invites |
| 4 | +--- |
| 5 | + |
| 6 | +# SmartThings Edge Driver Development Workflow |
| 7 | + |
| 8 | +This skill covers environment setup, driver deployment to hubs, and sharing |
| 9 | +drivers with other users through channels and invite links. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Environment Setup |
| 14 | + |
| 15 | +### 1. Install Lua 5.3 |
| 16 | + |
| 17 | +Edge Drivers are Lua-based. Install the Lua 5.3 runtime for local development |
| 18 | +and linting: |
| 19 | + |
| 20 | +```bash |
| 21 | +# Ubuntu / Debian |
| 22 | +sudo apt install lua5.3 |
| 23 | + |
| 24 | +# macOS |
| 25 | +brew install lua@5.3 |
| 26 | + |
| 27 | +# Windows |
| 28 | +# Download the Lua 5.3 binary from https://luabinaries.sourceforge.net/download.html |
| 29 | +# Or install via scoop: |
| 30 | +scoop install lua |
| 31 | +# Or via chocolatey: |
| 32 | +choco install lua53 |
| 33 | +``` |
| 34 | + |
| 35 | +### 2. lua_libs Directory |
| 36 | + |
| 37 | +The `lua_libs/` directory contains the SmartThings Lua libraries that are |
| 38 | +available on the hub at runtime. These correspond to the assets attached to the |
| 39 | +latest release on GitHub: |
| 40 | + |
| 41 | +<https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/releases/latest> |
| 42 | + |
| 43 | +Download the lua_libs archive from the release assets and |
| 44 | +extract it into the repository root if it is missing or needs updating. |
| 45 | + |
| 46 | +### 3. Configure LUA_PATH |
| 47 | + |
| 48 | +Set `LUA_PATH` so that `require` resolves both your driver modules and the |
| 49 | +SmartThings library modules in `lua_libs/`: |
| 50 | + |
| 51 | +```bash |
| 52 | +export LUA_PATH="./?.lua;./?/init.lua;$(pwd)/lua_libs/?.lua;$(pwd)/lua_libs/?/init.lua;;" |
| 53 | +``` |
| 54 | + |
| 55 | +Run it from the repository root so `$(pwd)` resolves correctly. |
| 56 | + |
| 57 | + |
| 58 | +### 4. Install the SmartThings CLI |
| 59 | + |
| 60 | +The CLI is required for packaging, deploying, and managing drivers and |
| 61 | +channels on the platform. |
| 62 | + |
| 63 | +```bash |
| 64 | +# Via npm (requires Node.js >= 24.8.0) |
| 65 | +npm install -g @smartthings/cli |
| 66 | + |
| 67 | +# macOS via Homebrew |
| 68 | +brew install smartthingscommunity/smartthings/smartthings |
| 69 | + |
| 70 | +# Linux / Windows |
| 71 | +# Download the binary or installer from: |
| 72 | +# https://github.com/SmartThingsCommunity/smartthings-cli/releases |
| 73 | +``` |
| 74 | + |
| 75 | +Verify the installation: |
| 76 | + |
| 77 | +```bash |
| 78 | +smartthings --version |
| 79 | +``` |
| 80 | + |
| 81 | +The CLI uses browser-based OAuth login by default. Run `smartthings devices` to trigger |
| 82 | +the login flow. |
| 83 | + |
| 84 | +### 5. Python Requirements (Testing) |
| 85 | + |
| 86 | +Some test and tooling scripts require Python dependencies: |
| 87 | + |
| 88 | +```bash |
| 89 | +pip install -r tools/requirements.txt |
| 90 | +``` |
| 91 | + |
| 92 | +### 6. Install Luacheck (Linting) |
| 93 | + |
| 94 | +Luacheck provides static analysis for Lua source files. It requires LuaRocks |
| 95 | +(the Lua package manager). |
| 96 | + |
| 97 | +**Install LuaRocks first:** |
| 98 | + |
| 99 | +```bash |
| 100 | +# Ubuntu / Debian |
| 101 | +sudo apt install luarocks |
| 102 | + |
| 103 | +# macOS |
| 104 | +brew install luarocks |
| 105 | + |
| 106 | +# Windows |
| 107 | +# Download the installer from https://luarocks.org/releases/ |
| 108 | +# Or via chocolatey: |
| 109 | +choco install luarocks |
| 110 | +``` |
| 111 | + |
| 112 | +**Then install Luacheck:** |
| 113 | + |
| 114 | +```bash |
| 115 | +# Via LuaRocks (all platforms) |
| 116 | +luarocks install luacheck |
| 117 | + |
| 118 | +# macOS alternative (installs both luarocks and luacheck) |
| 119 | +brew install luacheck |
| 120 | +``` |
| 121 | + |
| 122 | +Run it against a driver directory: |
| 123 | + |
| 124 | +```bash |
| 125 | +luacheck --config .github/workflows/.luacheckrc drivers/SmartThings/zigbee-switch/ |
| 126 | +``` |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Deploying Drivers |
| 131 | + |
| 132 | +### Overview |
| 133 | + |
| 134 | +Deploying a driver to a physical hub requires three things: |
| 135 | + |
| 136 | +1. A **channel** you own. |
| 137 | +2. The hub **enrolled** in that channel. |
| 138 | +3. The driver **packaged and uploaded** through the CLI. |
| 139 | + |
| 140 | +### Step 1: Create a Channel |
| 141 | + |
| 142 | +```bash |
| 143 | +smartthings edge:channels:create |
| 144 | +``` |
| 145 | + |
| 146 | +You will be prompted for a name and description. Note the returned channel ID. |
| 147 | + |
| 148 | +### Step 2: Enroll Your Hub |
| 149 | + |
| 150 | +```bash |
| 151 | +smartthings edge:channels:enroll <hub-id> |
| 152 | +``` |
| 153 | + |
| 154 | +Select the channel when prompted, or pass `--channel <channel-id>`. |
| 155 | + |
| 156 | +Find your hub ID with: |
| 157 | + |
| 158 | +```bash |
| 159 | +smartthings devices --type HUB |
| 160 | +``` |
| 161 | + |
| 162 | +### Step 3: Package and Install the Driver |
| 163 | + |
| 164 | +The `edge:drivers:package` command can build, upload, assign to a channel, and |
| 165 | +install in one step: |
| 166 | + |
| 167 | +```bash |
| 168 | +smartthings edge:drivers:package <path-to-driver-dir> \ |
| 169 | + --hub=<hub-uuid> \ |
| 170 | + --channel=<channel-id> |
| 171 | +``` |
| 172 | + |
| 173 | +For example: |
| 174 | + |
| 175 | +```bash |
| 176 | +smartthings edge:drivers:package drivers/SmartThings/zwave-switch \ |
| 177 | + --hub=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee \ |
| 178 | + --channel=11111111-2222-3333-4444-555555555555 |
| 179 | +``` |
| 180 | + |
| 181 | +### Other Useful Deployment Commands |
| 182 | + |
| 183 | +```bash |
| 184 | +# List drivers installed on a hub |
| 185 | +smartthings edge:drivers:installed --hub=<hub-uuid> |
| 186 | + |
| 187 | +# Stream logs from a driver on the hub |
| 188 | +smartthings edge:drivers:logcat <driver-id> --hub=<hub-uuid> |
| 189 | + |
| 190 | +# Uninstall a driver from a hub |
| 191 | +smartthings edge:drivers:uninstall <driver-id> --hub=<hub-uuid> |
| 192 | + |
| 193 | +# Remove unused drivers from a hub |
| 194 | +smartthings edge:drivers:prune --hub=<hub-uuid> |
| 195 | + |
| 196 | +# Switch a device to a different driver |
| 197 | +smartthings edge:drivers:switch <device-id> |
| 198 | +``` |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## Sharing Drivers |
| 203 | + |
| 204 | +### Creating an Invite Link |
| 205 | + |
| 206 | +Invite links let other users install your driver from your channel without |
| 207 | +giving them ownership of the driver or channel. |
| 208 | + |
| 209 | +```bash |
| 210 | +smartthings edge:channels:invites:create |
| 211 | +``` |
| 212 | + |
| 213 | +You will be prompted to select a channel and a driver. The command returns an |
| 214 | +invite URL of the form: |
| 215 | + |
| 216 | +``` |
| 217 | +https://bestow-regional.api.smartthings.com/invite/<invite-id> |
| 218 | +``` |
| 219 | + |
| 220 | +Share this URL with users. They open it in a browser or the SmartThings mobile |
| 221 | +app to accept the invitation. |
| 222 | + |
| 223 | +### Enrollment Flow for Recipients |
| 224 | + |
| 225 | +1. The recipient opens the invite link. |
| 226 | +2. They log in to their Samsung / SmartThings account. |
| 227 | +3. They select a hub to enroll in the channel. |
| 228 | +4. The driver can be selected to install to that hub. |
| 229 | + |
| 230 | +### Managing Invites |
| 231 | + |
| 232 | +```bash |
| 233 | +# List existing invites |
| 234 | +smartthings edge:channels:invites |
| 235 | + |
| 236 | +# Delete an invite |
| 237 | +smartthings edge:channels:invites:delete <invite-id> |
| 238 | +``` |
| 239 | + |
| 240 | +### Managing Channel Assignments |
| 241 | + |
| 242 | +```bash |
| 243 | +# Assign a specific driver version to a channel |
| 244 | +smartthings edge:channels:assign <driver-id> <version> |
| 245 | + |
| 246 | +# List drivers assigned to a channel |
| 247 | +smartthings edge:channels:drivers <channel-id> |
| 248 | + |
| 249 | +# Remove a driver from a channel |
| 250 | +smartthings edge:channels:unassign <driver-id> |
| 251 | +``` |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +## Quick Reference |
| 256 | + |
| 257 | +| Task | Command | |
| 258 | +|------|---------| |
| 259 | +| Create channel | `smartthings edge:channels:create` | |
| 260 | +| Enroll hub | `smartthings edge:channels:enroll <hub-id>` | |
| 261 | +| Package & deploy | `smartthings edge:drivers:package <dir> --hub=<id> --channel=<id>` | |
| 262 | +| Stream logs | `smartthings edge:drivers:logcat <driver-id> --hub=<id>` | |
| 263 | +| Create invite | `smartthings edge:channels:invites:create` | |
| 264 | +| List installed drivers | `smartthings edge:drivers:installed --hub=<id>` | |
0 commit comments