2000 lines
49 KiB
Markdown
2000 lines
49 KiB
Markdown
|
||
```
|
||
https://95598.csg.cn/ucs/ma/wt/center/loginByPwdAndMsg
|
||
```
|
||
|
||
```
|
||
rPP8KQa4bMsYfb1WJk39bLN269jnH0ylJLR8lg3OaZiQ0cL7c2bl0j6xi4tNl5fRVNCzUm+NSElK8QRuJt3+GfxP2hEDH1cy41ouOKTg85A4/OqkOJvcXaEmY0Kx5CPEH97XdZOjhxfN37uhx3C4V/csLWCMmskcR8V7zViZ1Bw=
|
||
```
|
||
|
||
|
||
|
||
|
||
|
||
```json
|
||
[
|
||
{
|
||
"id":"70a132e8642a3f17",
|
||
"type":"tab",
|
||
"label":"CSG-Web",
|
||
"disabled":false,
|
||
"info":"",
|
||
"env":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"d78eba36a05463ae",
|
||
"type":"inject",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"refresh token",
|
||
"props":[
|
||
{
|
||
"p":"payload"
|
||
},
|
||
{
|
||
"p":"topic",
|
||
"vt":"str"
|
||
}
|
||
],
|
||
"repeat":"1800",
|
||
"crontab":"",
|
||
"once":true,
|
||
"onceDelay":0.1,
|
||
"topic":"",
|
||
"payload":"",
|
||
"payloadType":"date",
|
||
"x":140,
|
||
"y":40,
|
||
"wires":[
|
||
[
|
||
"68f242dd11ffd2df"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"68f242dd11ffd2df",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"手工:设置环境",
|
||
"func":"//------------以下内容需要初始化start\n//web页面调试得到的值\n//登陆请求的payload\nvar login_request_body = {\n \"param\": \"you login param\"\n};\n//网关路由,不同地区可能稍有不同\nvar gateway = \"/ucs/ma/wt\";\n//------------以下内容需要初始化end\n\n\n\nvar login = gateway + '/center/login';\n//查询用户id\nvar queryBindEleUsers = gateway + '/eleCustNumber/queryBindEleUsers';\n//用电日历\nvar queryDayElectricByMPoint = gateway + '/charge/queryDayElectricByMPoint';\n//查询上个周期账单\nvar queryLatelyBillElec = gateway + '/charge/queryLatelyBillElec';\n//获取年度电费明细\nvar getAnalyzeFeeDetails = gateway + '/charge/getAnalyzeFeeDetails';\n//获取账户明细\nvar queryUserAccountNumberSurplus = gateway + '/charge/queryUserAccountNumberSurplus';\n\nflow.set(\"login_request_body\", login_request_body);\n\nvar host = \"https://95598.csg.cn\";\nflow.set('login_url', host + login);\nflow.set('queryBindEleUsers_url', host + queryBindEleUsers);\nglobal.set('queryDayElectricByMPoint_url', host + queryDayElectricByMPoint);\nglobal.set('queryLatelyBillElec_url', host + queryLatelyBillElec);\nglobal.set('getAnalyzeFeeDetails_url', host + getAnalyzeFeeDetails);\nglobal.set('queryUserAccountNumberSurplus_url', host + queryUserAccountNumberSurplus);\n//----调试用\n// global.set('headers',);\n// global.set('bindingId',);\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":340,
|
||
"y":40,
|
||
"wires":[
|
||
[
|
||
"6fa8b8b472e60cc1"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"6fa8b8b472e60cc1",
|
||
"type":"switch",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"judge headers",
|
||
"property":"headers",
|
||
"propertyType":"global",
|
||
"rules":[
|
||
{
|
||
"t":"null"
|
||
},
|
||
{
|
||
"t":"nnull"
|
||
}
|
||
],
|
||
"checkall":"true",
|
||
"repair":false,
|
||
"outputs":2,
|
||
"x":540,
|
||
"y":40,
|
||
"wires":[
|
||
[
|
||
"f38d3bcab9b9895e"
|
||
],
|
||
[
|
||
"43a5c83c1802c11e"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"f38d3bcab9b9895e",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"parms",
|
||
"func":"global.set(\"headers\",);\nglobal.set(\"bindingId\",);\n\nmsg.url = flow.get(\"login_url\");\n\nmsg.headers = {\n 'need-crypto': 'true'\n};\nmsg.payload = flow.get(\"login_request_body\");\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":130,
|
||
"y":140,
|
||
"wires":[
|
||
[
|
||
"4de928d88d602e98"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"c8579e962f91c95b",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print headers",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"$globalContext(\"headers\")",
|
||
"targetType":"jsonata",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":410,
|
||
"y":280,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"4de928d88d602e98",
|
||
"type":"http request",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"login request",
|
||
"method":"POST",
|
||
"ret":"obj",
|
||
"paytoqs":"ignore",
|
||
"url":"",
|
||
"tls":"",
|
||
"persist":true,
|
||
"proxy":"",
|
||
"insecureHTTPParser":false,
|
||
"authType":"",
|
||
"senderr":false,
|
||
"headers":[
|
||
|
||
],
|
||
"x":330,
|
||
"y":140,
|
||
"wires":[
|
||
[
|
||
"3259b9644949bdc0"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"3259b9644949bdc0",
|
||
"type":"switch",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"judge sta",
|
||
"property":"payload.sta",
|
||
"propertyType":"msg",
|
||
"rules":[
|
||
{
|
||
"t":"eq",
|
||
"v":"00",
|
||
"vt":"str"
|
||
}
|
||
],
|
||
"checkall":"true",
|
||
"repair":false,
|
||
"outputs":1,
|
||
"x":520,
|
||
"y":140,
|
||
"wires":[
|
||
[
|
||
"f8b4491a33b0db96"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"f8b4491a33b0db96",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"set headers",
|
||
"func":"if (msg.payload.sta == \"00\") {\n var alteonP = msg.headers[\"set-cookie\"][0];\n var x_auth_token = msg.headers[\"x-auth-token\"];\n var cookie = {\n 'Cookie': 'is-login=true;' + alteonP + ';' + \"token=\" + x_auth_token\n };\n var headers = {\n 'x-auth-token': x_auth_token,\n 'Cookie': cookie\n };\n global.set(\"headers\", headers);\n}\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":710,
|
||
"y":140,
|
||
"wires":[
|
||
[
|
||
"43a5c83c1802c11e"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"43a5c83c1802c11e",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"parms",
|
||
"func":"msg.url = flow.get(\"queryBindEleUsers_url\");\n\nmsg.headers = global.get(\"headers\");\n\nmsg.payload = \"\";\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":110,
|
||
"y":220,
|
||
"wires":[
|
||
[
|
||
"bc3889186f252bc8",
|
||
"c8579e962f91c95b"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"160bf8da74db98ff",
|
||
"type":"switch",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"judge sta",
|
||
"property":"payload.sta",
|
||
"propertyType":"msg",
|
||
"rules":[
|
||
{
|
||
"t":"eq",
|
||
"v":"00",
|
||
"vt":"str"
|
||
},
|
||
{
|
||
"t":"neq",
|
||
"v":"00",
|
||
"vt":"str"
|
||
}
|
||
],
|
||
"checkall":"true",
|
||
"repair":false,
|
||
"outputs":2,
|
||
"x":700,
|
||
"y":220,
|
||
"wires":[
|
||
[
|
||
"21c7dba7fe0522b0"
|
||
],
|
||
[
|
||
"f38d3bcab9b9895e"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"21c7dba7fe0522b0",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"set bindingId & areaCode",
|
||
"func":"if (msg.payload.sta == \"00\") {\n global.set(\"bindingId\", msg.payload.data[0].bindingId);\n global.set(\"areaCode\", msg.payload.data[0].areaCode);\n}\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":930,
|
||
"y":220,
|
||
"wires":[
|
||
[
|
||
"1bd7784ffbed3f73"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"bc3889186f252bc8",
|
||
"type":"http request",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"queryBindEleUsers request",
|
||
"method":"POST",
|
||
"ret":"obj",
|
||
"paytoqs":"ignore",
|
||
"url":"",
|
||
"tls":"",
|
||
"persist":true,
|
||
"proxy":"",
|
||
"insecureHTTPParser":false,
|
||
"authType":"",
|
||
"senderr":false,
|
||
"headers":[
|
||
|
||
],
|
||
"x":460,
|
||
"y":220,
|
||
"wires":[
|
||
[
|
||
"160bf8da74db98ff",
|
||
"a1987beb19a366f0"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"1bd7784ffbed3f73",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print bindingId",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"$globalContext(\"bindingId\")",
|
||
"targetType":"jsonata",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":1160,
|
||
"y":220,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"a704c1fba120eb99",
|
||
"type":"inject",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"timestamp",
|
||
"props":[
|
||
{
|
||
"p":"payload"
|
||
},
|
||
{
|
||
"p":"topic",
|
||
"vt":"str"
|
||
}
|
||
],
|
||
"repeat":"",
|
||
"crontab":"00 08 * * *",
|
||
"once":true,
|
||
"onceDelay":"30",
|
||
"topic":"",
|
||
"payload":"",
|
||
"payloadType":"date",
|
||
"x":110,
|
||
"y":380,
|
||
"wires":[
|
||
[
|
||
"0449970f69815f7b"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"13f1892ed45f7ca9",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"parms",
|
||
"func":"msg.url = global.get(\"queryDayElectricByMPoint_url\");\nmsg.headers = global.get(\"headers\");\n\nmsg.payload = {\n \"eleCustId\": global.get(\"bindingId\"),\n \"areaCode\": global.get(\"areaCode\"),\n \"yearMonth\": flow.get(\"time\")\n}\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":310,
|
||
"y":580,
|
||
"wires":[
|
||
[
|
||
"c6171a1c5545c6b6"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"0449970f69815f7b",
|
||
"type":"moment",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"set year month",
|
||
"topic":"",
|
||
"input":"payload",
|
||
"inputType":"msg",
|
||
"inTz":"Asia/Shanghai",
|
||
"adjAmount":"1",
|
||
"adjType":"days",
|
||
"adjDir":"subtract",
|
||
"format":"YYYYMM",
|
||
"locale":"C",
|
||
"output":"time",
|
||
"outputType":"flow",
|
||
"outTz":"Asia/Shanghai",
|
||
"x":120,
|
||
"y":460,
|
||
"wires":[
|
||
[
|
||
"40bf5364f75c47cb",
|
||
"6a0a1ad0bbdf4a9f"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"c6171a1c5545c6b6",
|
||
"type":"http request",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"queryDayElectricByMPoint",
|
||
"method":"POST",
|
||
"ret":"obj",
|
||
"paytoqs":"ignore",
|
||
"url":"",
|
||
"tls":"",
|
||
"persist":true,
|
||
"proxy":"",
|
||
"insecureHTTPParser":false,
|
||
"authType":"",
|
||
"senderr":false,
|
||
"headers":[
|
||
|
||
],
|
||
"x":400,
|
||
"y":480,
|
||
"wires":[
|
||
[
|
||
"5df9badb7e0bd0f4",
|
||
"d84bdc5152c9a72b",
|
||
"0e564672a07df746",
|
||
"533a26f4b28aa099",
|
||
"7be86af5844547ac",
|
||
"c542eab5ab16f7b3"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"5df9badb7e0bd0f4",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取最近日电量(有1-2天延迟)",
|
||
"func":"var arr = msg.payload.data.result; \nvar lastDate = arr[arr.length - 1].date; \nvar lastDatePower = arr[arr.length - 1].power;\n\nmsg.payload = {};\nmsg.payload.lastDate = lastDate;\nmsg.payload.lastDatePower = lastDatePower;\nmsg.payload.lastDatePowerDesc = lastDate + \"\\u3000\" + lastDatePower;\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":770,
|
||
"y":340,
|
||
"wires":[
|
||
[
|
||
"018e513df4dfd26b"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"018e513df4dfd26b",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"最近日电量",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"LastDate_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"kWh"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.lastDatePower",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"lastDatePower",
|
||
"value":"payload.lastDatePower",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"lastDate",
|
||
"value":"payload.lastDate",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"lastDatePowerDesc",
|
||
"value":"payload.lastDatePowerDesc",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1010,
|
||
"y":340,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"d84bdc5152c9a72b",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取当月总电量",
|
||
"func":"var Power = msg.payload.data.totalPower;\n\nmsg.payload = {};\n\nmsg.payload.Power = parseFloat(Power);\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":720,
|
||
"y":520,
|
||
"wires":[
|
||
[
|
||
"6505d98d229d41b5"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"6505d98d229d41b5",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"当月电量",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"CurMonth_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"kWh"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total_increasing"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.Power",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"Power",
|
||
"value":"payload.Power",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"month",
|
||
"value":"payload.Month",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1000,
|
||
"y":520,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"0e564672a07df746",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"查询当月每日明细",
|
||
"func":"const unit = \"kwh\\n\";\n\nvar arr = msg.payload.data.result; //数组取值\n\nvar result =\"\";\narr.forEach(function(value, index) {\n result += index + 1 + \"、\" + value.date + \":\" + value.power + unit; \n});\n\nmsg.payload = result;\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":730,
|
||
"y":400,
|
||
"wires":[
|
||
[
|
||
"23996c57fe9f99a5"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"23996c57fe9f99a5",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"当月每日明细",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"EveryDay_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"everyDayListed",
|
||
"stateType":"str",
|
||
"attributes":[
|
||
{
|
||
"property":"everyDayListed",
|
||
"value":"payload",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1020,
|
||
"y":400,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"533a26f4b28aa099",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"查询当月每日明细2",
|
||
"func":"var a = msg.payload.data.result; //数组取值\n\nvar date = a.map((item) => { //取date字段,形成新的数组\n return item.date;\n });\nvar power = a.map((item) => { //取power字段,形成新的数组\n return item.power;\n });\n\nmsg.payload = {\n \"date\" : date,\n \"power\": power\n}\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":730,
|
||
"y":460,
|
||
"wires":[
|
||
[
|
||
"629369baf3067e34",
|
||
"a578e1b4c5e75a22"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"629369baf3067e34",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"当月每日明细2",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"EveryDay_Power2"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"everyDayListed",
|
||
"stateType":"str",
|
||
"attributes":[
|
||
{
|
||
"property":"date",
|
||
"value":"payload.date",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"power",
|
||
"value":"payload.power",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1020,
|
||
"y":460,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"7be86af5844547ac",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"当月电费计算",
|
||
"func":"//获取当月总用电量\nvar currentMonthPower = parseFloat(msg.payload.data.totalPower);\n\n// var currentMonthPower = 460;\n//获取阶梯电价配置\nvar phase = flow.get(\"phase\").reverse();\n\nvar currentMonthFee = 0.0;\n\nphase.forEach(function (phaseValue) { \n if (currentMonthPower > phaseValue.power) {\n currentMonthFee += Number(phaseValue.price) * (currentMonthPower - phaseValue.power);\n currentMonthPower -= currentMonthPower - phaseValue.power;\n }\n});\n\nmsg.payload.curMonthFee = parseFloat(currentMonthFee.toFixed(2));\n// msg.payload.curMonthFee = parseInt(currentMonthFee);\n\nreturn msg;\n\n// var phase1 = (phase1Power * phase1Price);\n// var phase2 = (phase1Power * phase1Price +((phase2Power - phase1Power) * phase2Price));//定义第2档电量收费\n\n// if(power <= phase1Power){\n// curMonthFee = power * phase1Price //电量*单价\n// }else if(power <= phase2Power){\n// curMonthFee = phase1 + ((power - phase1Power) * phase2Price)\n// }else{\n// curMonthFee = (phase2 + (power - phase2Power) * phase3Price)\n// }\n\n// curMonthFee= (curMonthFee).toFixed(2);\n\n\n// msg.payload.curMonthPower = Power;\n// msg.payload.phase1Price = phase1Price;\n// msg.payload.phase2Price = phase2Price;\n// msg.payload.phase3Price = phase3Price;\n// msg.payload.curMonthFee = curMonthFee;\n// msg.payload.phase1Power = phase1Power;\n// msg.payload.phase2Power = phase2Power;\n// msg.payload.phase1 = phase1;\n// msg.payload.phase2 = phase2;\n// msg.payload.isSummer = isSummer;\n\n/**\n// * 根据输入的电量计算当月电费\n// * @param {number} currentPower\n// */\n// function CalcPowerFee(currentPower){\n// var currentMonthFee = 0.0;\n// phase.forEach(function (price, power) {\n// if (currentPower > power) {\n// currentMonthFee += Number(price) * (currentPower - power);\n// }\n// });\n// return currentMonthFee.toFixed(2);\n// }",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":720,
|
||
"y":580,
|
||
"wires":[
|
||
[
|
||
"89baf0e4aa23bcc9"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"89baf0e4aa23bcc9",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"预计当月电费",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"CurMonth_Fee"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:currency-cny"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"CNY"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.curMonthFee",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"Fee",
|
||
"value":"payload.curMonthFee",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1020,
|
||
"y":580,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"40bf5364f75c47cb",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"手工:初始化电价",
|
||
"func":"const arrSummer = [5, 6, 7, 8, 9, 10]; //设置5-10为夏季\nconst month = parseInt(flow.get(\"time\").substr(4, 2));\n//如果系统时间的月份数在5-10内,则为夏季,否则为冬季\nconst isSummer = arrSummer.indexOf(month) != -1 ? true : false;\n\n//单价数据来源:https://95598.csg.cn/#/gd/serviceInquire/LRLayer/elePriceInquire\n//定义电价数组,自行通过上述链接查询后填充\nconst phase = [\n {\n \"price\": 0.58886875,\n \"power\": 0\n },\n {\n \"price\": 0.63886875,\n //夏季260,冬季200\n \"power\": isSummer ? 260 : 200\n },\n {\n \"price\": 0.88886875,\n //夏季600,冬季400\n \"power\": isSummer ? 600 : 400\n }\n];\nflow.set(\"phase\",phase);\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":130,
|
||
"y":520,
|
||
"wires":[
|
||
[
|
||
"ebcab05cf5e72e01"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"6a0a1ad0bbdf4a9f",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print time",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"$flowContext(\"time\")",
|
||
"targetType":"jsonata",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":340,
|
||
"y":400,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"ebcab05cf5e72e01",
|
||
"type":"switch",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"judge headers",
|
||
"property":"headers",
|
||
"propertyType":"global",
|
||
"rules":[
|
||
{
|
||
"t":"nnull"
|
||
}
|
||
],
|
||
"checkall":"true",
|
||
"repair":false,
|
||
"outputs":1,
|
||
"x":120,
|
||
"y":580,
|
||
"wires":[
|
||
[
|
||
"13f1892ed45f7ca9",
|
||
"da74629af82b6d92",
|
||
"910e4009522b96be",
|
||
"e53165982311bd50",
|
||
"1599a9ce46129107"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"c542eab5ab16f7b3",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print payload",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"payload",
|
||
"targetType":"msg",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":490,
|
||
"y":340,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"da74629af82b6d92",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"parms",
|
||
"func":"msg.url = global.get(\"queryLatelyBillElec_url\");\n\nmsg.headers = global.get(\"headers\");\n\nmsg.payload = {\n \"eleCustId\": global.get(\"bindingId\"),\n \"areaCode\": global.get(\"areaCode\")\n};\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":90,
|
||
"y":720,
|
||
"wires":[
|
||
[
|
||
"1df787e0b4bf4b49"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"1df787e0b4bf4b49",
|
||
"type":"http request",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"queryLatelyBillElec",
|
||
"method":"POST",
|
||
"ret":"obj",
|
||
"paytoqs":"ignore",
|
||
"url":"",
|
||
"tls":"",
|
||
"persist":false,
|
||
"proxy":"",
|
||
"insecureHTTPParser":false,
|
||
"authType":"",
|
||
"senderr":false,
|
||
"headers":[
|
||
|
||
],
|
||
"x":310,
|
||
"y":720,
|
||
"wires":[
|
||
[
|
||
"bb509d4e9e271408"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"bb509d4e9e271408",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取上月电费、上月电量、结算周期数据",
|
||
"func":"msg.payload.LastMonthFee = msg.payload.data.totalElectricity;\nmsg.payload.LastMonthPower = msg.payload.data.totalPower;\nmsg.payload.period = msg.payload.data.electricityBillYearMonth;\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":700,
|
||
"y":720,
|
||
"wires":[
|
||
[
|
||
"b6f0b6bfef5e882c",
|
||
"07c1d27f0e881e6e",
|
||
"1d6debd422b13123"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"b6f0b6bfef5e882c",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"上月电量",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"LastMonth_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"kWh"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.LastMonthPower",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"period",
|
||
"value":"payload.period",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"LastMonthPower",
|
||
"value":"payload.LastMonthPower",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1000,
|
||
"y":680,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"07c1d27f0e881e6e",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"上月电费",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"LastMonth_Fee"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:currency-cny"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"CNY"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.LastMonthFee",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"period",
|
||
"value":"payload.period",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1000,
|
||
"y":760,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"1d6debd422b13123",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print payload",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"payload",
|
||
"targetType":"msg",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":730,
|
||
"y":800,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"910e4009522b96be",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"parms",
|
||
"func":"msg.url = global.get(\"getAnalyzeFeeDetails_url\");\nmsg.headers = global.get(\"headers\");\n\nmsg.payload = {\n \"eleCustId\": global.get(\"bindingId\"),\n \"areaCode\": global.get(\"areaCode\"),\n \"electricityBillYear\": parseInt(flow.get(\"time\").substr(0, 4))\n};\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":110,
|
||
"y":920,
|
||
"wires":[
|
||
[
|
||
"714b47b7b4f25e2b"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"714b47b7b4f25e2b",
|
||
"type":"http request",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"getAnalyzeFeeDetails",
|
||
"method":"POST",
|
||
"ret":"obj",
|
||
"paytoqs":"ignore",
|
||
"url":"",
|
||
"tls":"",
|
||
"persist":false,
|
||
"proxy":"",
|
||
"insecureHTTPParser":false,
|
||
"authType":"",
|
||
"senderr":false,
|
||
"headers":[
|
||
|
||
],
|
||
"x":300,
|
||
"y":920,
|
||
"wires":[
|
||
[
|
||
"30dedb1b57915633",
|
||
"f2a58d0f23d43621",
|
||
"245e6a1c38d5cf40"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"30dedb1b57915633",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取本年电量数据",
|
||
"func":"\nmsg.payload.yearFee = msg.payload.data.totalActualAmount;\n\nmsg.payload.yearPower = msg.payload.data.totalBillingElectricity;\n\n\n\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":630,
|
||
"y":940,
|
||
"wires":[
|
||
[
|
||
"437aa8323a0e86ef",
|
||
"485f07ce3199bb83"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"437aa8323a0e86ef",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"今年总电量",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"year_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"kWh"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.yearPower",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"yearPower",
|
||
"value":"payload.yearPower",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1010,
|
||
"y":920,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"485f07ce3199bb83",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"今年总电费",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"year_Fee"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:currency-cny"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"CNY"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.yearFee",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1010,
|
||
"y":980,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"f2a58d0f23d43621",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取今年各月明细",
|
||
"func":"var a = msg.payload.data.electricAndChargeList; //数组取值\nvar yearMonth = a.map((item, index) => { //取date字段,形成新的数组\n return item.yearMonthStart;\n });\n\n\nvar power = a.map((item, index) => { //取power字段,形成新的数组\n return item.billingElectricity;\n });\n \nvar fee = a.map((item, index) => { //取power字段,形成新的数组\n return item.actualTotalAmount;\n }); \n \n\n \nmsg.payload ={\n \"yearMonth\":yearMonth,\n \"power\":power,\n \"fee\":fee\n}\nreturn msg;\n",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":630,
|
||
"y":880,
|
||
"wires":[
|
||
[
|
||
"8b670fac79b6b0dc"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"8b670fac79b6b0dc",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"今年各月明细",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"EveryMonth_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"everyDayListed",
|
||
"stateType":"str",
|
||
"attributes":[
|
||
{
|
||
"property":"yearMonth",
|
||
"value":"payload.yearMonth",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"power",
|
||
"value":"payload.power",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"fee",
|
||
"value":"payload.fee",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1020,
|
||
"y":860,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"245e6a1c38d5cf40",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print payload",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"payload",
|
||
"targetType":"msg",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":610,
|
||
"y":1000,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"9f2275baa52b711a",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取去年电量数据",
|
||
"func":"\nmsg.payload.yearFee = msg.payload.data.totalActualAmount;\n\nmsg.payload.yearPower = msg.payload.data.totalBillingElectricity;\n\n\n\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":630,
|
||
"y":1100,
|
||
"wires":[
|
||
[
|
||
"d44043343a455d4a",
|
||
"70fa8d114ef045b3"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"d44043343a455d4a",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"去年总电量",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"lastYear_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"kWh"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.yearPower",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"yearPower",
|
||
"value":"payload.yearPower",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1010,
|
||
"y":1060,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"70fa8d114ef045b3",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"去年总电费",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"lastYear_Fee"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:currency-cny"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"CNY"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload.yearFee",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
{
|
||
"property":"yearFee",
|
||
"value":"payload.yearFee",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1010,
|
||
"y":1140,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"58294338de973b53",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取去年各月明细",
|
||
"func":"var a = msg.payload.data.electricAndChargeList; //数组取值\nvar yearMonth = a.map((item, index) => { //取date字段,形成新的数组\n return item.yearMonthStart;\n });\n\n\nvar power = a.map((item, index) => { //取power字段,形成新的数组\n return item.billingElectricity;\n });\n \nvar fee = a.map((item, index) => { //取power字段,形成新的数组\n return item.actualTotalAmount;\n }); \n \n\n \nmsg.payload ={\n \"yearMonth\":yearMonth,\n \"power\":power,\n \"fee\":fee\n}\nreturn msg;\n",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":630,
|
||
"y":1200,
|
||
"wires":[
|
||
[
|
||
"92255df0762477fb"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"92255df0762477fb",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"去年各月明细",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"lastYearEveryMonth_Power"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:home-lightning-bolt"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":""
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"everyDayListed",
|
||
"stateType":"str",
|
||
"attributes":[
|
||
{
|
||
"property":"yearMonth",
|
||
"value":"payload.yearMonth",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"power",
|
||
"value":"payload.power",
|
||
"valueType":"msg"
|
||
},
|
||
{
|
||
"property":"fee",
|
||
"value":"payload.fee",
|
||
"valueType":"msg"
|
||
}
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":1020,
|
||
"y":1200,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"e53165982311bd50",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"parms",
|
||
"func":"msg.url = global.get(\"getAnalyzeFeeDetails_url\");\nmsg.headers = global.get(\"headers\");\n\nmsg.payload = {\n \"eleCustId\": global.get(\"bindingId\"),\n \"areaCode\": global.get(\"areaCode\"),\n \"electricityBillYear\": parseInt(flow.get(\"time\").substr(0, 4)) - 1\n};\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":110,
|
||
"y":1100,
|
||
"wires":[
|
||
[
|
||
"9af09574fdd6755a"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"9af09574fdd6755a",
|
||
"type":"http request",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"getAnalyzeFeeDetails",
|
||
"method":"POST",
|
||
"ret":"obj",
|
||
"paytoqs":"ignore",
|
||
"url":"",
|
||
"tls":"",
|
||
"persist":false,
|
||
"proxy":"",
|
||
"insecureHTTPParser":false,
|
||
"authType":"",
|
||
"senderr":false,
|
||
"headers":[
|
||
|
||
],
|
||
"x":300,
|
||
"y":1100,
|
||
"wires":[
|
||
[
|
||
"9f2275baa52b711a",
|
||
"58294338de973b53",
|
||
"b6c4ce659d5a2acb"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"b6c4ce659d5a2acb",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print payload",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"payload",
|
||
"targetType":"msg",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":610,
|
||
"y":1060,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"a1987beb19a366f0",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print payload",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"payload",
|
||
"targetType":"msg",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":710,
|
||
"y":280,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"a578e1b4c5e75a22",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print payload",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"payload",
|
||
"targetType":"msg",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":1210,
|
||
"y":520,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"1599a9ce46129107",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"parms",
|
||
"func":"msg.url = global.get(\"queryUserAccountNumberSurplus_url\");\nmsg.headers = global.get(\"headers\");\n\nmsg.payload = {\n \"eleCustId\": global.get(\"bindingId\"),\n \"areaCode\": global.get(\"areaCode\")\n};\n\nreturn msg;",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":110,
|
||
"y":1300,
|
||
"wires":[
|
||
[
|
||
"42cab46a662c4f40"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"42cab46a662c4f40",
|
||
"type":"http request",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"queryUserAccountNumberSurplus",
|
||
"method":"POST",
|
||
"ret":"obj",
|
||
"paytoqs":"ignore",
|
||
"url":"",
|
||
"tls":"",
|
||
"persist":false,
|
||
"proxy":"",
|
||
"insecureHTTPParser":false,
|
||
"authType":"",
|
||
"senderr":false,
|
||
"headers":[
|
||
|
||
],
|
||
"x":340,
|
||
"y":1300,
|
||
"wires":[
|
||
[
|
||
"1544432f98ab15f0"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"92581437f66c92f5",
|
||
"type":"debug",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"print payload",
|
||
"active":false,
|
||
"tosidebar":true,
|
||
"console":false,
|
||
"tostatus":false,
|
||
"complete":"payload",
|
||
"targetType":"msg",
|
||
"statusVal":"",
|
||
"statusType":"auto",
|
||
"x":730,
|
||
"y":1380,
|
||
"wires":[
|
||
|
||
]
|
||
},
|
||
{
|
||
"id":"1544432f98ab15f0",
|
||
"type":"function",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"获取账户余额",
|
||
"func":"msg.payload = parseFloat(msg.payload.data[0].balance);\nreturn msg;\n",
|
||
"outputs":1,
|
||
"noerr":0,
|
||
"initialize":"",
|
||
"finalize":"",
|
||
"libs":[
|
||
|
||
],
|
||
"x":600,
|
||
"y":1300,
|
||
"wires":[
|
||
[
|
||
"92581437f66c92f5",
|
||
"f630d5e3bc7c9376"
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"f630d5e3bc7c9376",
|
||
"type":"ha-entity",
|
||
"z":"70a132e8642a3f17",
|
||
"name":"账户余额",
|
||
"server":"8473da4d3c8e0016",
|
||
"version":2,
|
||
"debugenabled":false,
|
||
"outputs":1,
|
||
"entityType":"sensor",
|
||
"config":[
|
||
{
|
||
"property":"name",
|
||
"value":"electric_account_balance"
|
||
},
|
||
{
|
||
"property":"device_class",
|
||
"value":"energy"
|
||
},
|
||
{
|
||
"property":"icon",
|
||
"value":"mdi:currency-cny"
|
||
},
|
||
{
|
||
"property":"unit_of_measurement",
|
||
"value":"CNY"
|
||
},
|
||
{
|
||
"property":"state_class",
|
||
"value":"total"
|
||
},
|
||
{
|
||
"property":"last_reset",
|
||
"value":""
|
||
}
|
||
],
|
||
"state":"payload",
|
||
"stateType":"msg",
|
||
"attributes":[
|
||
|
||
],
|
||
"resend":true,
|
||
"outputLocation":"payload",
|
||
"outputLocationType":"none",
|
||
"inputOverride":"allow",
|
||
"outputOnStateChange":false,
|
||
"outputPayload":"",
|
||
"outputPayloadType":"str",
|
||
"x":960,
|
||
"y":1300,
|
||
"wires":[
|
||
[
|
||
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"id":"8473da4d3c8e0016",
|
||
"type":"server",
|
||
"name":"Home Assistant",
|
||
"version":4,
|
||
"addon":true,
|
||
"rejectUnauthorizedCerts":true,
|
||
"ha_boolean":"y|yes|true|on|home|open",
|
||
"connectionDelay":false,
|
||
"cacheJson":true,
|
||
"heartbeat":false,
|
||
"heartbeatInterval":"30",
|
||
"areaSelector":"friendlyName",
|
||
"deviceSelector":"friendlyName",
|
||
"entitySelector":"friendlyName",
|
||
"statusSeparator":"at: ",
|
||
"statusYear":"hidden",
|
||
"statusMonth":"short",
|
||
"statusDay":"numeric",
|
||
"statusHourCycle":"h23",
|
||
"statusTimeFormat":"h:m"
|
||
}
|
||
]
|
||
|
||
```
|
||
|
||
|
||
|
||
|
||
https://95598.csg.cn/ucs/ma/wt/center/loginByPwdAndMsg
|
||
```json
|
||
{
|
||
"areaCode": "030000",
|
||
"acctId": "13822217956",
|
||
"logonChan": "3",
|
||
"code": "231806",
|
||
"credType": "1011",
|
||
"credentials": "rPP8KQa4bMsYfb1WJk39bLN269jnH0ylJLR8lg3OaZiQ0cL7c2bl0j6xi4tNl5fRVNCzUm+NSElK8QRuJt3+GfxP2hEDH1cy41ouOKTg85A4/OqkOJvcXaEmY0Kx5CPEH97XdZOjhxfN37uhx3C4V/csLWCMmskcR8V7zViZ1Bw="
|
||
}
|
||
```
|
||
|
||
|
||
|
||
https://95598.csg.cn/ucs/ma/wt/center/login
|
||
```
|
||
{
|
||
"param": "LxpWMSNJrtTnO/TclCSCDIII/XSr8uYqQKqiLpjPRmekt19JHUvYhkm0yHNIvsfam14eLRdmaxAMLAD1lsnWzUxEiu5RqcQQrvUd7yivO5+e5agHG+Z/TGxHiWFojDTJ"
|
||
}
|
||
``` |