AgentSkillsCN

ha-modbus-integration

构建 Home Assistant 自定义集成的模式,支持 Modbus(TCP/RTU-over-TCP/串行):pymodbus device_id 使用、安全轮询/写入、速率控制/退避、多寄存器值编码、缓存回退以及翻译支持实体。

SKILL.md
--- frontmatter
name: ha-modbus-integration
description: Patterns for building Home Assistant custom integrations that talk Modbus (TCP/RTU-over-TCP/serial): pymodbus device_id usage, safe polling/writing, pacing/backoff, encoding multi-register values, cached fallback, and translation-backed entities.
license: Complete terms in LICENSE.txt

HA Modbus Integration

Use this when implementing or refactoring HA custom components that communicate with Modbus devices.

Quick start

  • Pick connection mode (tcp, rtuovertcp, serial); set timeout and message spacing.
  • Always pass the correct unit id (device_id/slave) on every read/write.
  • Batch contiguous reads, lock IO, and tier polling; cache last good data for availability.
  • Encode multi-register writes (float32/uint32) and avoid immediate post-write refresh.
  • Use translation_key + entity.sensor names and stable unique/device ids.

References