add home mdx

This commit is contained in:
2025-11-30 13:03:01 +08:00
parent 769f15aaf2
commit ecca716c83
6 changed files with 552 additions and 480 deletions

View File

@@ -0,0 +1,26 @@
---
import '../styles/global.css';
export interface Props {
title?: string;
description?: string;
}
const { title, description } = Astro.props;
---
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>{title || '文档'}</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github-dark.min.css">
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-8 max-w-4xl">
<article class="markdown-body bg-white rounded-lg shadow-lg p-8">
<slot />
</article>
</div>
</body>
</html>

View File

@@ -1,3 +1,9 @@
---
title: "Home 配置文档"
description: "Home Assistant 自动化配置文档"
layout: ../layouts/MDXPost.astro
---
# home配置文档
## configuration.yaml
@@ -5,6 +11,7 @@
配置调用rest_command服务文件地址在 docker 内部根目录下,`config/configuration.yaml` 位置
添加以下内容
```yaml
rest_command:
set_floor_notify:
@@ -12,8 +19,8 @@ rest_command:
method: POST
content_type: application/json
```
然后配置脚本位置 `config/scripts.yaml` 文件,添加以下内容
(scripts 被 configuration.yaml 引用)
然后配置脚本位置 `config/scripts.yaml` 文件,添加以下内容(scripts 被 configuration.yaml 引用
```yaml
notify_floor:
@@ -22,7 +29,9 @@ notify_floor:
sequence:
- service: rest_command.set_floor_notify
```
## 触发使用
home 可视化页面可以编辑自动化,编辑后台也可以,在 automations.yaml 文件中添加以下类似内容
```yaml

View File

@@ -1,3 +1,8 @@
---
title: "Python 代码示例"
description: "SIP 消息发送和 FastAPI 服务示例"
---
# python 代码示例
```sh
@@ -122,9 +127,9 @@ async def router(path: str = Query(...)):
result = await test()
else:
return {"error": f"Unknown path: {path}"}
return {"success": True, "data": result}
except Exception as e:
return {"success": False, "error": str(e)}