---
title: "โมเดล Things และ MQTT"
description: "มุมมองของเซิร์ฟเวอร์ที่ไม่ผูกกับแพลตฟอร์มใด ในรูปอุปกรณ์ที่มีความสามารถ สำหรับ Home Assistant, MQTT และแพลตฟอร์มบ้านอัจฉริยะอื่นๆ"
url: https://vigiora.com/th/docs/home-assistant/things-and-mqtt
updated: 2026-11-03T13:14:28.000Z
---

# โมเดล Things และ MQTT

> มุมมองของเซิร์ฟเวอร์ที่ไม่ผูกกับแพลตฟอร์มใด ในรูปอุปกรณ์ที่มีความสามารถ สำหรับ Home Assistant, MQTT และแพลตฟอร์มบ้านอัจฉริยะอื่นๆ

**โมเดล Things** อธิบายเซิร์ฟเวอร์ Vigiora แบบที่แพลตฟอร์มบ้านอัจฉริยะคิด: เป็นอุปกรณ์ (*things*) ที่มี*ความสามารถ* (capabilities) แต่ละความสามารถมีสถานะ คำสั่ง และเหตุการณ์ ส่วนเชื่อมต่อ Vigiora สำหรับ Home Assistant สร้างบนโมเดลนี้ และแพลตฟอร์มอื่นใดก็ใช้ได้ด้วยตารางจับคู่ของตนเอง

โมเดลนี้เป็นส่วนหนึ่งของ [public API v1](https://vigiora.com/docs/developers/api-v1) ตั้งแต่ API 1.18 (แคตตาล็อก 1.1 ตั้งแต่ API 1.25) เป็นตัวปรับต่อ (adapter) บน API v1 ไม่ใช่ API ที่สอง: สิ่งที่คีย์มองเห็นและสิ่งที่คำสั่งทำได้ ถูกกำหนดโดยการดำเนินการที่มีอยู่ พร้อมขอบเขต บทบาท สิทธิ์ของกล้อง ขีดจำกัดอัตรา การตรวจสอบ และคลาส [human in the loop](https://vigiora.com/docs/developers/human-in-the-loop)

## Endpoint

| Endpoint | ขอบเขต | สิ่งที่ให้ |
| --- | --- | --- |
| `GET /api/v1/thing-capabilities` | คีย์ใดก็ได้ | แคตตาล็อก: ชนิด ความสามารถ สคีมาของสถานะ คำสั่ง เหตุการณ์ |
| `GET /api/v1/things` | `cameras:read` | ทุก thing ที่คีย์มองเห็นได้ พร้อมสถานะของความสามารถ `?kind=` ใช้กรอง |
| `GET /api/v1/things/{thing_id}` | `cameras:read` | thing หนึ่งรายการ |
| `POST /api/v1/things/{thing_id}/commands/{capability}.{command}` | ขอบเขตของการดำเนินการที่คำสั่งเรียก | เรียกคำสั่ง เนื้อหาคำขอเก็บพารามิเตอร์ |
| `GET /api/v1/events/stream?format=things` | `events:read` | เหตุการณ์สดในรูปแบบ envelope ของ Things (Server-Sent Events) |
| `GET /api/v1/server` | คีย์ใดก็ได้ | ตัวตนของเซิร์ฟเวอร์และ `features` เพื่อตรวจว่าเซิร์ฟเวอร์รองรับอะไร |

## Things

| ชนิด | Id | คืออะไร |
| --- | --- | --- |
| `server` | `server` | เซิร์ฟเวอร์ Vigiora |
| `camera` | `camera:<id>` | กล้อง |
| `microphone` | `microphone:<id>` | ไมโครโฟน USB |
| `speaker` | `speaker:<id>` | เอาต์พุตลำโพง (ผู้ดูแลระบบและผู้ปฏิบัติงาน) |
| `room` | `room:<id>` | ห้อง |
| `area` | `area:<id>` | พื้นที่วิเคราะห์ (`analytics:read`) |
| `external` | `ha:<entity_id>` | อุปกรณ์ Home Assistant ที่แชร์กับ Vigiora ผ่าน[บริดจ์](https://vigiora.com/docs/home-assistant/bridge) (`devices:read` ผู้ดูแลระบบและผู้ปฏิบัติงาน) แคตตาล็อก 1.1 |

thing แต่ละรายการมี `id`, `kind`, `name`, `source` (`vigiora` หรือ `home-assistant`), `parent_id`, `site_id`, `room_ids`, `online` (`true`, `false` หรือ `null` เมื่อไม่ทราบ), `manufacturer`, `model` และ `capabilities`

## ความสามารถ

| ความสามารถ | อยู่บน | คำสั่ง |
| --- | --- | --- |
| `device` | server, camera, microphone | ไม่มี (เหตุการณ์ออนไลน์และออฟไลน์) |
| `video_stream` | camera | `get_url`: ลิงก์ HLS อายุสั้นที่ลงนามแล้ว |
| `snapshot` | camera | `get_url`: ลิงก์รูปภาพที่ลงนามแล้ว |
| `motion` | camera ที่มีการตรวจจับการเคลื่อนไหว | ไม่มี (เหตุการณ์ `started`, `ended`) |
| `presence` | camera | ไม่มี (เหตุการณ์ `changed`) |
| `object_detection` | camera | ไม่มี (เหตุการณ์ `detected`) |
| `alert` | server, camera, microphone | `acknowledge` |
| `recording` | camera, microphone | `turn_on`, `turn_off` |
| `ai_guardian` | camera | `turn_on`, `turn_off` |
| `ai_mode` | room | `set` (live, guardian, both) |
| `ptz` | camera ที่มี PTZ | `move`, `stop`, `goto_preset` |
| `speak` | camera ที่มีลำโพง, speaker, room | `say` |
| `describe` | camera | `run` |
| `detect_objects` | camera | `run` |
| `occupancy` | area | ไม่มี (จำนวน ความจุ ที่ว่าง) |
| `counter` | area | ไม่มี (เข้าและออกวันนี้) |

อุปกรณ์ Home Assistant เพิ่ม `contact`, `value`, `onoff`, `brightness`, `lock`, `alarm_mode`, `siren` และ `notify` ดู[อุปกรณ์แต่ละประเภททำอะไรได้](https://vigiora.com/docs/home-assistant/bridge#what-each-kind-of-device-can-do)

แคตตาล็อกระบุการดำเนินการที่แต่ละคำสั่งเรียก ขอบเขตและบทบาท และคลาส `hitl`: `confirm` หมายความว่าเอเจนต์ AI ต้องได้รับการอนุมัติจากคนขณะที่ human in the loop เปิดอยู่

## คำสั่ง

คำสั่งหนึ่งคำสั่งเรียกการดำเนินการที่มีอยู่เพียงหนึ่งรายการในนามของผู้เรียก ตัวอย่างเช่น:

```bash
curl -s -X POST https://yourname.vigiora.com/api/v1/things/camera:12/commands/speak.say \
  -H "Authorization: Bearer vgk_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello"}'
```

คำสั่งนี้เรียก `POST /api/v1/cameras/12/actions/speak` และตอบกลับด้วย `thing_id`, `command`, `operation_id` และ `result` ของการดำเนินการนั้นเอง ข้อผิดพลาดเป็นของการดำเนินการนั้นโดยไม่เปลี่ยนแปลง คำสั่งที่ thing ไม่มีจะตอบ `404 not_found`

endpoint ของคำสั่งเป็น REST เท่านั้น ไม่ใช่เครื่องมือ MCP: เอเจนต์ AI เรียกการดำเนินการเองโดยตรง ซึ่ง human in the loop มีผล

## เหตุการณ์

`GET /api/v1/events/stream?format=things` ส่งแต่ละเหตุการณ์ในรูปแบบ envelope ของ [CloudEvents 1.0](https://cloudevents.io):

```json
{
  "specversion": "1.0",
  "id": "01JC0Z8Q4M1V6N3B7X2K5T9W0A",
  "source": "vigiora://<server id>/things/camera:12",
  "type": "vigiora.motion.started",
  "subject": "camera:12",
  "time": "2026-11-02T13:05:00.123Z",
  "datacontenttype": "application/json",
  "dataschema": "vigiora:things:1.0:vigiora.motion.started",
  "data": { "started_at": "2026-11-02T13:05:00.120Z" },
  "vigioracapability": "motion",
  "vigioracatalogversion": "1.0",
  "vigioraeventtype": "motion.started"
}
```

ประเภทเป็นรูปแบบ `vigiora.<capability>.<event>` เช่น `vigiora.presence.changed`, `vigiora.alert.created` หรือ `vigiora.ai_guardian.observed` อุปกรณ์ Home Assistant ที่แชร์ส่ง `vigiora.<capability>.changed` โดยมี subject เป็น `ha:<entity_id>` `?types=` ยังคงกรองตามประเภทเหตุการณ์ปกติของ API v1 ลิงก์รูปภาพใน `data` ลงนามสำหรับผู้อ่านและใช้ได้ 15 นาที

## เขียนตัวปรับต่อของคุณเอง

1. ดึงรายการ thing และแคตตาล็อก ใช้ `id` ของแต่ละ thing เป็น id ที่ไม่ซ้ำในแพลตฟอร์มของคุณ
2. จับคู่แต่ละความสามารถกับเอนทิตีประเภทหนึ่งของแพลตฟอร์มด้วยตาราง: หนึ่งแถวต่อหนึ่งความสามารถ พร้อมฟิลด์สถานะที่อ่านและคำสั่งที่ส่ง
3. สมัครรับ `?format=things` และอัปเดตสถานะจาก `type` และ `subject`
4. ต่ออายุลิงก์วิดีโอที่ลงนาม (`video_stream.get_url`) ก่อนหมดอายุ
5. ตรวจ `features` ใน `GET /api/v1/server` ก่อน: `things` และ `things_event_format` หมายความว่าเซิร์ฟเวอร์รองรับโมเดลนี้ หากได้ `404` แสดงว่าเซิร์ฟเวอร์เก่ากว่า API 1.17

### ตัวอย่าง MQTT

เพื่อแสดงว่าโมเดลนี้ไม่ได้ผูกกับส่วนเชื่อมต่อของ Home Assistant เซิร์ฟเวอร์มีตัวปรับต่อตัวที่สองบนโมเดลเดียวกัน: ตั้งแต่เวอร์ชัน 1.6.15 Vigiora เผยแพร่แต่ละ thing ไปยัง MQTT broker พร้อม **MQTT discovery** ของ Home Assistant สถานะแบบ retained เหตุการณ์ และคำสั่งหากคุณอนุญาต ฟีเจอร์นี้มีในตัว ตั้งค่าได้ที่ **ระบบ → การผสานรวม → MQTT** ดูการตั้งค่าและ topic ได้ที่ [การผสานรวม](https://vigiora.com/docs/admin/integrations#mqtt)

## หน้าที่เกี่ยวข้อง

- [Vigiora และ Home Assistant](https://vigiora.com/docs/home-assistant/overview)
- [ใช้อุปกรณ์ Home Assistant ใน Vigiora](https://vigiora.com/docs/home-assistant/bridge)
- [Public API v1](https://vigiora.com/docs/developers/api-v1)
- [Webhooks และเหตุการณ์](https://vigiora.com/docs/developers/webhooks-and-events)
- [การผสานรวม](https://vigiora.com/docs/admin/integrations)

---

Source: https://vigiora.com/th/docs/home-assistant/things-and-mqtt · Last updated 3 Nov 2026, 13:14 UTC
