跳到主要内容

Service Control

Update service-level parameters—timezone, schedules, system settings—on a provisioned node.

备注

userInstanceESPRMUser from User sign in.

What This Module Does ?

Device Control handles lights, switches, and other controllable devices. Service control updates system-level parameters on services in the node config (schedules, timezone, OTA settings, etc.) via setValue() on service parameters.

Use this when updating service parameters. For timezone only, node.setTimeZone() is simpler. For device params, use Device Control.

Expected outcome: The service parameter update is applied on the node.

Common Workflows

Set timezone via Time service

const { nodes } = await userInstance.getUserNodes();
const node = nodes[0];
const nodeConfig = node.nodeConfig ?? (await node.getNodeConfig());

const timeService = nodeConfig.services.find((s) => s.type === "esp.service.time");
const tzParam = timeService.params.find((p) => p.name === "TZ");

await tzParam.setValue("America/Los_Angeles");
  1. Get node — getUserNodes() or getNodeDetails(nodeId)
  2. Access services — nodeConfig.services or getServices()
  3. Find service — by type (e.g., "esp.service.time")
  4. Find parameter — by name or type
  5. setValue(newValue)

Use getServices() directly

const services = await node.getServices();
const timeService = services.find((s) => s.type === "esp.service.time");
const tzParam = timeService.params.find((p) => p.name === "TZ");
await tzParam.setValue("Asia/Kolkata");

Find parameters by type

const tzParam = service.params.find((p) => p.type === "esp.param.tz");
if (tzParam) await tzParam.setValue("Europe/London");

Error Handling

try {
const nodeConfig = node.nodeConfig ?? (await node.getNodeConfig());
const service = nodeConfig.services.find((s) => s.type === "esp.service.time");
const param = service?.params.find((p) => p.name === "TZ");
if (!service || !param) return;
await param.setValue(timezone);
} catch (error) {
console.error("Failed to update service parameter:", error);
}

Advanced Concepts

Node hierarchy for services

Node → Services → Service Parameters

Devices and services are siblings under nodeConfig; control paths are parallel—see Device Control for the device side.

Best Practices

  1. Verify the service exists on the node before updating
  2. Match by type when names vary by firmware
  3. Use setTimeZone() for timezone-only changes
  4. Batch updates with setMultipleParams() when changing several values

On this page