Files
2024-11-15 10:02:13 -08:00
..
2024-01-10 16:23:51 -08:00
2024-09-20 15:52:12 -07:00
2024-01-10 16:23:51 -08:00
2022-02-11 15:34:29 -08:00
2024-11-15 10:02:13 -08:00
2024-11-15 10:02:13 -08:00
2022-02-11 15:34:29 -08:00
2022-11-02 17:21:31 -07:00

Use the Scrypted SDK from the command line or web

import { connectScryptedClient, OnOff } from '@scrypted/client';

async function example() {
    const sdk = await connectScryptedClient({
        baseUrl: 'https://localhost:10443',
        pluginId: "@scrypted/core",
        username: process.env.SCRYPTED_USERNAME || 'admin',
        password: process.env.SCRYPTED_PASSWORD || 'swordfish',
    });

    const dimmer = sdk.systemManager.getDeviceByName<OnOff>("Office Dimmer");
    dimmer.turnOn();
    await new Promise(resolve => setTimeout(resolve, 5000));
    await dimmer.turnOff(); 
    // allow node to exit
    sdk.disconnect();
}

example();

Running the Example

npm -g install ts-node
ts-node examples/example.ts