[{"id":"c429b7e20e810b79","type":"function","z":"43c4ac0f789b8957","name":"获取最小电量实体信息","func":"var entities = msg.payload;\nvar minPowerConsumption = Infinity;\nvar minPowerEntity = null;\n\n// 遍历所有实体,找到电量最低的实体\nfor (var i = 0; i < entities.length; i++) {\n var entity = entities[i];\n var entityId = entity.entity_id;\n var powerConsumption = parseFloat(entity.state);\n if (powerConsumption < minPowerConsumption) {\n minPowerConsumption = powerConsumption;\n minPowerEntity = entity;\n }\n}\n\n// 如果找到了最小电量实体,则发送钉钉消息\nif (minPowerEntity) {\n msg.payload = minPowerEntity;\n return msg;\n}\nelse {\n return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":840,"wires":[["5abc141b338836ce","2534eb8fc02baff1"]]},{"id":"5abc141b338836ce","type":"function","z":"43c4ac0f789b8957","name":"构建消息内容","func":"var entity = msg.payload;\nvar entityId = entity.entity_id;\nvar powerConsumption = entity.state;\nvar message = `实体ID:${entityId}\n电量:${powerConsumption}`;\n\nmsg.payload = {\n data: {\n message: message\n }\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":840,"wires":[["084f612255f56782","74a524341fb7eb74"]]},{"id":"084f612255f56782","type":"api-call-service","z":"43c4ac0f789b8957","name":"发送钉钉消息","server":"98872d0b.46fd6","version":5,"debugenabled":false,"domain":"notify","service":"dingtalk","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":960,"y":840,"wires":[["a0da4f2b4840c287"]]},{"id":"a0da4f2b4840c287","type":"debug","z":"43c4ac0f789b8957","name":"debug 44","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1140,"y":840,"wires":[]},{"id":"2e60d5500b242e3e","type":"server-state-changed","z":"43c4ac0f789b8957","name":"","server":"98872d0b.46fd6","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.*battery","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"hours","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":250,"y":840,"wires":[["c429b7e20e810b79","2751c96cb893f20e"]]},{"id":"98872d0b.46fd6","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]