[
{
"id": "d80206f1def63828",
"type": "function",
"z": "e9514e52a1f8e5cf",
"name": "6:00到22:00",
"func": "function timeToMinutes(timeStr) {\n const [hours, minutes] = timeStr.split(':').map(Number);\n return hours * 60 + minutes;\n}\nvar nowTime = timeToMinutes(`${new Date().getHours().toString().padStart(2, '0')}:${new Date().getMinutes().toString().padStart(2, '0')}`);\nif (nowTime > 360 && nowTime < 1320){\n return { payload: "on" }\n}else{\n return { payload: "off" }\n}\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 2120,
"wires": [
[
"fdd0fa502f14cf00"
]
]
},
{
"id": "fdd0fa502f14cf00",
"type": "switch",
"z": "e9514e52a1f8e5cf",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
},
{
"t": "eq",
"v": "off",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 450,
"y": 2120,
"wires": [
[
"af5179c503689ffc"
],
[
"cad8a0da03afc726"
]
]
},
{
"id": "bc079345c4ec9553",
"type": "inject",
"z": "e9514e52a1f8e5cf",
"name": "开灯",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 2120,
"wires": [
[
"d80206f1def63828"
]
]
},
{
"id": "af5179c503689ffc",
"type": "api-current-state",
"z": "e9514e52a1f8e5cf",
"name": "检查空调状态 为关",
"server": "df3fa6f0d06a05bd",
"version": 3,
"outputs": 2,
"halt_if": "off",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "",
"state_type": "str",
"blockInputOverrides": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 630,
"y": 2080,
"wires": [
[
"150526bfe14504c2"
],
[]
]
},
{
"id": "150526bfe14504c2",
"type": "api-call-service",
"z": "e9514e52a1f8e5cf",
"name": "打开空调",
"server": "df3fa6f0d06a05bd",
"version": 7,
"debugenabled": false,
"action": "",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [],
"labelId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": true,
"domain": "",
"service": "",
"x": 820,
"y": 2080,
"wires": [
[]
]
},
{
"id": "cad8a0da03afc726",
"type": "api-current-state",
"z": "e9514e52a1f8e5cf",
"name": "检查空调状态 为开",
"server": "df3fa6f0d06a05bd",
"version": 3,
"outputs": 2,
"halt_if": "off",
"halt_if_type": "str",
"halt_if_compare": "is_not",
"entity_id": "",
"state_type": "str",
"blockInputOverrides": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 630,
"y": 2140,
"wires": [
[
"05be7ab558a6e1d2"
],
[]
]
},
{
"id": "05be7ab558a6e1d2",
"type": "api-call-service",
"z": "e9514e52a1f8e5cf",
"name": "关闭空调",
"server": "df3fa6f0d06a05bd",
"version": 7,
"debugenabled": false,
"action": "",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [],
"labelId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": true,
"domain": "",
"service": "",
"x": 820,
"y": 2140,
"wires": [
[]
]
},
{
"id": "1f115614e6e87476",
"type": "comment",
"z": "e9514e52a1f8e5cf",
"name": "在时间段内",
"info": "",
"x": 560,
"y": 2040,
"wires": []
},
{
"id": "2e35ab37c44e3bf0",
"type": "comment",
"z": "e9514e52a1f8e5cf",
"name": "在时间段外",
"info": "",
"x": 560,
"y": 2180,
"wires": []
},
{
"id": "df3fa6f0d06a05bd",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": false,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
}
]