Service Control
Update service-level parameters—timezone, schedules, system settings—on a provisioned node.
note
userInstance — ESPRMUser 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");
Navigate to a service parameter
- Get node —
getUserNodes()orgetNodeDetails(nodeId) - Access services —
nodeConfig.servicesorgetServices() - Find service — by
type(e.g.,"esp.service.time") - Find parameter — by
nameortype 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
- Verify the service exists on the node before updating
- Match by
typewhen names vary by firmware - Use
setTimeZone()for timezone-only changes - Batch updates with
setMultipleParams()when changing several values
Related Resource
- API Reference: