Skip to content

Instantly share code, notes, and snippets.

@0neday
Last active March 26, 2022 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0neday/5e967618027b4b44dd9980bf5a6bdebf to your computer and use it in GitHub Desktop.
Save 0neday/5e967618027b4b44dd9980bf5a6bdebf to your computer and use it in GitHub Desktop.
pzem 用电数据推送至企业微信,by nodered
[
{
"id": "1685f1b549464713",
"type": "tab",
"label": "推送每日用电数据",
"disabled": false,
"info": "自动推送每日用电数据到企业微信",
"env": []
},
{
"id": "dcbd8ed9f4179814",
"type": "inject",
"z": "1685f1b549464713",
"name": "每天8点发送用电信息",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "01 08 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 180,
"wires": [
[
"9f24f15912873f5b",
"82a8fda3f504513e",
"1dc399c57821bd14",
"5cd3531c2512bffd",
"ab4d9cb8358677ce",
"fa122f588b648059"
]
]
},
{
"id": "1dc399c57821bd14",
"type": "api-current-state",
"z": "1685f1b549464713",
"name": "昨日总电费",
"server": "e8349c19021c66e6",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sensor.yesterday_dianfei",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "yesterday_dianfei",
"valueType": "str"
}
],
"for": 0,
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 450,
"y": 200,
"wires": [
[
"9079d5405132fc31"
]
]
},
{
"id": "5cd3531c2512bffd",
"type": "api-current-state",
"z": "1685f1b549464713",
"name": "本月电量",
"server": "e8349c19021c66e6",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sensor.monthly_dianliang",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "monthly_dianliang",
"valueType": "str"
}
],
"for": 0,
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 440,
"y": 260,
"wires": [
[
"9079d5405132fc31"
]
]
},
{
"id": "9f24f15912873f5b",
"type": "api-current-state",
"z": "1685f1b549464713",
"name": "本月电费",
"server": "e8349c19021c66e6",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sensor.monthly_dianfei",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "monthly_dianfei",
"valueType": "str"
}
],
"for": 0,
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 440,
"y": 320,
"wires": [
[
"9079d5405132fc31"
]
]
},
{
"id": "82a8fda3f504513e",
"type": "api-current-state",
"z": "1685f1b549464713",
"name": "昨日总电量",
"server": "e8349c19021c66e6",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "num",
"halt_if_compare": "is",
"entity_id": "sensor.yesterday_dianliang",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "yesterday_dianliang",
"valueType": "str"
}
],
"for": 0,
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 450,
"y": 140,
"wires": [
[
"9079d5405132fc31"
]
]
},
{
"id": "191e9528bd400b33",
"type": "function",
"z": "1685f1b549464713",
"name": "微信消息预处理",
"func": "\nvar message=msg.payload;\nvar desc = '昨日峰电量:'+ message.yesterday_peek + 'KWH';\ndesc += '\\n昨日谷电量:'+ message.yesterday_offpeak + 'KWH';\ndesc += '\\n昨日总电量:'+ message.yesterday_dianliang + 'KWH';\ndesc += '\\n昨日电费:'+ message.yesterday_dianfei + '元';\ndesc += '\\n本月已用电量:'+ message.monthly_dianliang + 'KWH';\ndesc += '\\n本月已用电费:'+ message.monthly_dianfei + '元';\n\nwechat = {\"touser\" : \"@all\", \"msgtype\": \"text\", \n \"text\": {\n \"content\" : desc,\n \"safe\":1,\n \"enable_duplicate_check\": 0,\n \"duplicate_check_interval\": 1800\n\n }\n \n};\nmsg.payload = {};\nmsg.payload = wechat;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 840,
"y": 220,
"wires": [
[
"20afaf5df4e6c745"
]
]
},
{
"id": "20afaf5df4e6c745",
"type": "bizwechat-push",
"z": "1685f1b549464713",
"name": "",
"bizwechat": "6a3117af916e7140",
"x": 1020,
"y": 220,
"wires": [
[]
]
},
{
"id": "fa122f588b648059",
"type": "api-current-state",
"z": "1685f1b549464713",
"name": "昨日峰电量",
"server": "e8349c19021c66e6",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sensor.yesterday_peak_dianliang",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "yesterday_peek",
"valueType": "str"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 450,
"y": 20,
"wires": [
[
"9079d5405132fc31"
]
]
},
{
"id": "ab4d9cb8358677ce",
"type": "api-current-state",
"z": "1685f1b549464713",
"name": "昨日谷电量",
"server": "e8349c19021c66e6",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sensor.yesterday_offpeak_dianliang",
"state_type": "num",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "yesterday_offpeak",
"valueType": "str"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 450,
"y": 80,
"wires": [
[
"9079d5405132fc31"
]
]
},
{
"id": "9079d5405132fc31",
"type": "join",
"z": "1685f1b549464713",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "6",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 670,
"y": 140,
"wires": [
[
"833cbf4655e170cd",
"191e9528bd400b33"
]
]
},
{
"id": "833cbf4655e170cd",
"type": "debug",
"z": "1685f1b549464713",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 870,
"y": 140,
"wires": []
},
{
"id": "e8349c19021c66e6",
"type": "server",
"name": "Home Assistant",
"version": 2,
"addon": false,
"rejectUnauthorizedCerts": false,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": true,
"heartbeatInterval": "30"
},
{
"id": "6a3117af916e7140",
"type": "bizwechat-configurator",
"name": "noedred 企业微信推送",
"port": "",
"corpid": "",
"agentid": "",
"corpsecret": "",
"url": "",
"token": "TxuQCi98tY",
"aeskey": "22onCLmGPqdx4eoPXsqLVctbzFE17xOJlBDsVIdvxmj",
"client_id": "",
"client_secret": ""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment