[
{
"id": "cff13234.5d9ce",
"type": "api-get-history",
"z": "d01ca094.762a5",
"name": "",
"server": "94f0c0a9.629b6",
"startdate": "",
"enddate": "",
"entityid": "sensor.temperature_158d0000fd539c",
"entityidtype": "includes",
"useRelativeTime": true,
"relativeTime": "1day",
"output_type": "array",
"output_location_type": "msg",
"output_location": "payload",
"x": 950,
"y": 1740,
"wires": [
[
"91cca1c6.ce01c"
]
]
},
{
"id": "9e63c1e5.e81c5",
"type": "api-current-state",
"z": "d01ca094.762a5",
"name": "客厅当前温度",
"server": "94f0c0a9.629b6",
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"override_topic": true,
"override_payload": true,
"override_data": true,
"entity_id": "sensor.temperature_158d0000fd539c",
"state_type": "num",
"outputs": 1,
"x": 540,
"y": 1920,
"wires": [
[
"132990cb.dd89af",
"b658fd8d.d7d4b"
]
]
},
{
"id": "132990cb.dd89af",
"type": "debug",
"z": "d01ca094.762a5",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 750,
"y": 1820,
"wires": []
},
{
"id": "91cca1c6.ce01c",
"type": "change",
"z": "d01ca094.762a5",
"name": "转移变量",
"rules": [
{
"t": "move",
"p": "payload[0][0].state",
"pt": "msg",
"to": "temp_1day",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 1920,
"wires": [
[
"9e63c1e5.e81c5"
]
]
},
{
"id": "b658fd8d.d7d4b",
"type": "function",
"z": "d01ca094.762a5",
"name": "判断当前与昨天的温差",
"func": "let d_value = msg.temp_1day - msg.payload\nif(Math.abs(d_value) >=5){\n if(d_value<0){\n msg.d_result = `升温${Math.abs(d_value).toFixed(1)}摄氏度`;\n }\n else if(d_value>0){\n msg.d_result = `降温${Math.abs(d_value).toFixed(1)}摄氏度`;\n }\n else{\n msg.d_reslut = '';\n }\n}\nelse{\n msg.d_reslut = '';\n }\nmsg.temp_today = msg.payload;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 780,
"y": 1920,
"wires": [
[
"31a0e811.b19798",
"495e7ef8.e3817"
]
]
},
{
"id": "31a0e811.b19798",
"type": "debug",
"z": "d01ca094.762a5",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 1030,
"y": 1820,
"wires": []
},
{
"id": "c06a8b2e.c70218",
"type": "comment",
"z": "d01ca094.762a5",
"name": "开灯播报当前温度与昨天同时间的温差",
"info": "",
"x": 150,
"y": 1620,
"wires": []
},
{
"id": "fb12f9e4.83e6f8",
"type": "rbe",
"z": "d01ca094.762a5",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"property": "payload",
"x": 390,
"y": 1700,
"wires": [
[
"39680da4.735072"
]
]
},
{
"id": "8c3d7d37.2486c",
"type": "server-state-changed",
"z": "d01ca094.762a5",
"name": "监测客厅右键灯",
"server": "94f0c0a9.629b6",
"entityidfilter": "switch.wall_switch_right_158d00014cf47a",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"x": 80,
"y": 1700,
"wires": [
[
"a9c366c3.c8f4e8"
]
]
},
{
"id": "766b6dc2.82cf54",
"type": "switch",
"z": "d01ca094.762a5",
"name": "灯新状态为开启",
"property": "data.new_state.state",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 760,
"y": 1740,
"wires": [
[
"cff13234.5d9ce"
]
]
},
{
"id": "5898f714.7e07c8",
"type": "switch",
"z": "d01ca094.762a5",
"name": "灯新状态为关闭",
"property": "data.new_state.state",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "off",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 760,
"y": 1680,
"wires": [
[]
]
},
{
"id": "39680da4.735072",
"type": "switch",
"z": "d01ca094.762a5",
"name": "排除原状态为未知",
"property": "data.old_state.state",
"propertyType": "msg",
"rules": [
{
"t": "neq",
"v": "unavailable",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 550,
"y": 1700,
"wires": [
[
"766b6dc2.82cf54",
"5898f714.7e07c8"
]
]
},
{
"id": "d8740cde.c616",
"type": "api-call-service",
"z": "d01ca094.762a5",
"name": "小爱TTS",
"server": "94f0c0a9.629b6",
"service_domain": "hello_miai",
"service": "add2msgqueue",
"data": "",
"render_data": false,
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"x": 1260,
"y": 1920,
"wires": [
[]
]
},
{
"id": "f435e9b6.bffd18",
"type": "function",
"z": "d01ca094.762a5",
"name": "推送内容",
"func": "\nvar message = `现在室内温度是${msg.temp_today}摄氏度,${msg.d_result}`;\nmsg.payload = {};\nmsg.payload.data ={ message : message , miai_num : 0 };\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1120,
"y": 1920,
"wires": [
[
"d8740cde.c616"
]
]
},
{
"id": "495e7ef8.e3817",
"type": "switch",
"z": "d01ca094.762a5",
"name": "",
"property": "d_reslut",
"propertyType": "msg",
"rules": [
{
"t": "neq",
"v": "",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 990,
"y": 1920,
"wires": [
[
"f435e9b6.bffd18"
]
]
},
{
"id": "a9c366c3.c8f4e8",
"type": "time-range-switch",
"z": "d01ca094.762a5",
"name": "",
"lat": "",
"lon": "",
"startTime": "07:00",
"endTime": "09:30",
"startOffset": 0,
"endOffset": 0,
"x": 250,
"y": 1700,
"wires": [
[
"fb12f9e4.83e6f8"
],
[]
]
},
{
"id": "94f0c0a9.629b6",
"type": "server",
"z": "",
"name": "Home Assistant",
"legacy": true,
"hassio": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open"
}
]