[
{
"id": "c47395601e1189fd",
"type": "inject",
"z": "18f3d6ef71710367",
"name": "每天早上00:01",
"props": [
{
"p": "token",
"v": "YOUR_TOKEN_KEY",
"vt": "str"
}
],
"repeat": "",
"crontab": "01 00 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 180,
"y": 400,
"wires": [
[
"8974b6d77d75f52a"
]
]
},
{
"id": "8974b6d77d75f52a",
"type": "function",
"z": "18f3d6ef71710367",
"name": "获取当前日期",
"func": "// Function节点中的代码\nlet token = msg.token;\nlet now = new Date();\nlet year = now.getFullYear();\nlet month = ("0" + (now.getMonth() + 1)).slice(-2); // 加1因为月份是从0开始的\nlet day = ("0" + now.getDate()).slice(-2);\nlet formattedDate = year + "-" + month + "-" + day;\n\nmsg.url = `https://apis.tianapi.com/jiejiari/index?key=${token}&type=0&date=${formattedDate}`;\n\nmsg.payload = formattedDate;\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 420,
"y": 420,
"wires": [
[
"337cbee97c05d3e9"
]
]
},
{
"id": "337cbee97c05d3e9",
"type": "http request",
"z": "18f3d6ef71710367",
"name": "今天是否是节假日",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 630,
"y": 440,
"wires": [
[
"2f90222899418958"
]
]
},
{
"id": "2f90222899418958",
"type": "switch",
"z": "18f3d6ef71710367",
"name": "需要上班",
"property": "payload.result.list[0].isnotwork",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "str"
},
{
"t": "eq",
"v": "1",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 860,
"y": 460,
"wires": [
[
"ea836bd9da07fa1e"
],
[
"6485aea7e97c015c"
]
]
},
{
"id": "ea836bd9da07fa1e",
"type": "api-call-service",
"z": "18f3d6ef71710367",
"name": "需要上班",
"server": "69621d87.7af904",
"version": 5,
"debugenabled": false,
"domain": "input_boolean",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"input_boolean.ying_gai_shang_ban"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1040,
"y": 460,
"wires": [
[]
]
},
{
"id": "6485aea7e97c015c",
"type": "api-call-service",
"z": "18f3d6ef71710367",
"name": "不需要上班",
"server": "69621d87.7af904",
"version": 5,
"debugenabled": false,
"domain": "input_boolean",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"input_boolean.ying_gai_shang_ban"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1050,
"y": 520,
"wires": [
[]
]
},
{
"id": "69621d87.7af904",
"type": "server",
"name": "HA",
"addon": false,
"rejectUnauthorizedCerts": false,
"ha_boolean": "y|yes|true|on|home|open|工作日",
"connectionDelay": true,
"cacheJson": false,
"heartbeat": true,
"heartbeatInterval": "30",
"areaSelector": "id",
"deviceSelector": "id",
"entitySelector": "id",
"statusSeparator": "",
"statusYear": "2-digit",
"statusMonth": "2-digit",
"statusDay": "2-digit",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m:s",
"enableGlobalContextStore": false
}
]
4. 修改第一步中的TOKEN为你自己的, 修改HA配置。搞定