[{"id":"75d1cd431666fc49","type":"api-current-state","z":"6ce0f0465744cfa4","name":"日历","server":"9b9f41a8.34d99","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"calendar.zhong_guo","state_type":"str","blockInputOverrides":false,"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":250,"y":1580,"wires":[["6b6e012ebe2526a7"]]},{"id":"093120e87262ad8d","type":"inject","z":"6ce0f0465744cfa4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":1580,"wires":[["75d1cd431666fc49"]]},{"id":"6b6e012ebe2526a7","type":"function","z":"6ce0f0465744cfa4","name":"function 2","func":"// 获取当前日期并转换为毫秒数\nvar now = new Date();\nvar now_ms = now.getTime();\n\n// 获取实体属性日期并转换为毫秒数\n// 假设实体属性日期是msg.payload\nvar entity_date = new Date(msg.data.attributes.start_time);\nvar entity_date_ms = entity_date.getTime();\n\n// 计算差值并转换为天数\nvar diff_ms = now_ms - entity_date_ms;\nvar diff_days = Math.floor(diff_ms / (1000 * 60 * 60 * 24));\n\n// 返回差值\nmsg.payload = -diff_days;\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":1580,"wires":[["d7d64e7ae6af147b"]]},{"id":"d7d64e7ae6af147b","type":"ha-sensor","z":"6ce0f0465744cfa4","name":"","entityConfig":"280daa7788261365","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":630,"y":1580,"wires":[[]]},{"id":"9b9f41a8.34d99","type":"server","name":"我的家","version":5,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":false,"heartbeat":true,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":false},{"id":"280daa7788261365","type":"ha-entity-config","server":"9b9f41a8.34d99","deviceConfig":"","name":"red-letter day","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"red-letter day"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"天"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false}]
复制代码导入nodered