服务控制
在已配网的节点上更新服务参数,例如时区、定时和系统设置。
本模块的功能
设备控制负责灯、开关等可控设备。服务控制通过对服务参数调用 setValue(),更新节点配置中的系统级服务参数(定时、时区、OTA 设置等)。
适用场景:在更新服务参数时使用。若只修改时区,使用 node.setTimeZone() 更简单。若要修改设备参数,请使用设备控制。
预期结果: 服务参数更新将应用到该节点。
常见工作流
通过 Time 服务设置时区
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");

