[
{
"id": "fc9e39d782595312",
"type": "server-state-changed",
"z": "8cbab518550e3620",
"name": "总电表",
"server": "9000ff8.d3d7a",
"version": 3,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "sensor.zong_dian_liang",
"entityidfiltertype": "exact",
"outputinitially": true,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": false,
"for": 0,
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": true,
"ignoreCurrentStateUnavailable": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 90,
"y": 100,
"wires": [
[
"e5f1a45f4c8daf74"
]
]
},
{
"id": "e5f1a45f4c8daf74",
"type": "function",
"z": "8cbab518550e3620",
"name": "转换格式",
"func": "//获取位置人信息\nlet who = msg.topic.split(".")[1];\n//拼接MQTT地址\nlet topic = `energy/${who}`;\n//转换JSON\nlet res = msg.payload;\n\nmsg.topic = topic;\nmsg.payload = {"energy": Number(res),"starttime":"2021-1-1 00:00:00"}\n//显示位置 \nnode.status({\n text:who+":"+msg.payload\n}) \n//输出值\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 380,
"y": 100,
"wires": [
[
"fe82b3da56a8d045"
]
]
},
{
"id": "8b4ca3122e67a17e",
"type": "mqtt out",
"z": "8cbab518550e3620",
"name": "总电量",
"topic": "",
"qos": "0",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "fe3c94f2.6bfd58",
"x": 750,
"y": 100,
"wires": []
},
{
"id": "0c6e28652357ba83",
"type": "server-state-changed",
"z": "8cbab518550e3620",
"name": "冰箱电量",
"server": "9000ff8.d3d7a",
"version": 3,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "sensor.bingxiangdianliang",
"entityidfiltertype": "exact",
"outputinitially": true,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": false,
"for": 0,
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": true,
"ignoreCurrentStateUnavailable": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 100,
"y": 160,
"wires": [
[
"e5f1a45f4c8daf74"
]
]
},
{
"id": "fe82b3da56a8d045",
"type": "switch",
"z": "8cbab518550e3620",
"name": "过滤无效值",
"property": "payload.energy",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 590,
"y": 100,
"wires": [
[
"8b4ca3122e67a17e",
"e77c27fe45da17ff"
]
]
},
{
"id": "e77c27fe45da17ff",
"type": "debug",
"z": "8cbab518550e3620",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 180,
"wires": []
},
{
"id": "9000ff8.d3d7a",
"type": "server",
"name": "Home Assistant",
"version": 1,
"legacy": false,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true
},
{
"id": "fe3c94f2.6bfd58",
"type": "mqtt-broker",
"name": "MQTT",
"broker": "192.168.8.1",
"port": "1883",
"clientid": "",
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]