mcpField
H
ha-entities

ha-entities

github.com/laurigates其他5971 次安装1 天前更新
代码仓库

关于 ha-entities

面向 Home Assistant 用户和 Agent 的实体参考技能,介绍域、自定义、模板、组、属性与状态访问;不侧重自动化规则。

主要功能

  1. 01实体域与 ID 结构
  2. 02实体自定义
  3. 03模板传感器
  4. 04组与设备类别
  5. 05状态和属性访问

适用场景

  1. 01识别合适的实体域
  2. 02自定义实体名称和图标
  3. 03创建模板传感器
  4. 04在模板中读取实体状态

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/laurigates/claude-plugins --skill ha-entities

安装后在 Claude Code 中输入/ha-entities确认已加载。

附带文件REFERENCE.md

详细介绍

Home Assistant 实体

何时使用此技能

在以下情况下使用此技能……在以下情况下改用 ha-automations……
了解实体域创建自动化规则
自定义实体处理触发器/操作
创建模板传感器编写自动化条件
设置组处理脚本/场景
处理设备类别处理事件

实体 ID 结构

domain.object_id

示例:

  • light.living_room_ceiling
  • sensor.outdoor_temperature
  • binary_sensor.front_door_contact
  • switch.garden_irrigation

常见域

域描述示例
light照明控制light.kitchen
switch开/关开关switch.outlet
sensor数值传感器sensor.temperature
binary_sensor开/关传感器binary_sensor.motion
climateHVAC 控制climate.thermostat
cover百叶窗、车库门cover.garage
lock门锁lock.front_door
media_player媒体设备media_player.tv
camera摄像头画面camera.front_yard
vacuum扫地机器人vacuum.roomba
fan风扇控制fan.bedroom
alarm_control_panel报警系统alarm_control_panel.home
person人员追踪person.john
device_tracker设备位置device_tracker.phone
weather天气信息weather.home
input_boolean虚拟开关input_boolean.guest_mode
input_number虚拟数字input_number.target_temp
input_select虚拟下拉菜单input_select.house_mode
input_text虚拟文本input_text.message
input_datetime虚拟日期/时间input_datetime.alarm
input_button虚拟按钮input_button.reset
automation自动化automation.motion_light
script脚本script.morning_routine
scene场景scene.movie_night
group实体组group.all_lights
timer倒计时器timer.laundry
counter计数器counter.guests
zone地理区域zone.home
sun太阳位置sun.sun

完整的设备类别表(二进制传感器和传感器)请参阅 REFERENCE.md。

实体自定义

customize.yaml
# Single entity
light.living_room:
  friendly_name: "Living Room Light"
  icon: mdi:ceiling-light

# Binary sensor
binary_sensor.front_door:
  friendly_name: "Front Door"
  device_class: door

# Sensor
sensor.outdoor_temperature:
  friendly_name: "Outdoor Temperature"
  device_class: temperature
  unit_of_measurement: "°C"
Glob 自定义
customize_glob:
  "light.*_ceiling":
    icon: mdi:ceiling-light

  "sensor.*_temperature":
    device_class: temperature
    unit_of_measurement: "°C"

  "binary_sensor.*_motion":
    device_class: motion

模板传感器

template:
  - sensor:
      # Simple state
      - name: "Average Temperature"
        unit_of_measurement: "°C"
        device_class: temperature
        state: >-
          {{ ((states('sensor.living_room_temp') | float +
               states('sensor.bedroom_temp') | float +
               states('sensor.kitchen_temp') | float) / 3) | round(1) }}

      # With attributes
      - name: "Power Usage"
        unit_of_measurement: "W"
        device_class: power
        state: "{{ states('sensor.energy_meter_power') }}"
        attributes:
          cost_per_hour: >-
            {{ (states('sensor.energy_meter_power') | float * 0.15 / 1000) | round(2) }}

      # Availability
      - name: "Solar Power"
        unit_of_measurement: "W"
        device_class: power
        state: "{{ states('sensor.inverter_power') }}"
        availability: "{{ states('sensor.inverter_power') != 'unavailable' }}"

有关模板二进制传感器、开关、按钮、数字、组、实用计量器、计数器和计时器,请参阅 REFERENCE.md。

状态属性

常见属性
域常见属性
lightbrightness、color_temp、rgb_color、hs_color、effect
climatetemperature、current_temperature、hvac_action、preset_mode
media_playervolume_level、media_title、media_artist、source
covercurrent_position、current_tilt_position
weathertemperature、humidity、pressure、wind_speed、forecast
personsource、latitude、longitude、gps_accuracy
sunelevation、azimuth、next_rising、next_setting
访问属性
# In templates
{{ state_attr('light.living_room', 'brightness') }}
{{ state_attr('climate.thermostat', 'current_temperature') }}
{{ state_attr('sun.sun', 'elevation') }}

# In conditions
condition:
  - condition: numeric_state
    entity_id: light.living_room
    attribute: brightness
    above: 100

快速参考

状态函数
函数描述示例
states('entity')获取状态states('sensor.temp')
state_attr('entity', 'attr')获取属性state_attr('light.x', 'brightness')
is_state('entity', 'value')检查状态is_state('light.x', 'on')
is_state_attr('entity', 'attr', 'val')检查属性is_state_attr('climate.x', 'hvac_action', 'heating')
states.domain域中的所有实体states.light
expand('group.x')展开组成员expand('group.all_lights')

Agentic Optimizations

ContextCommand
Find entity usagegrep -r "entity_id:" config/ --include="*.yaml"
List customizationsgrep -rA2 "^[a-z_]*\\..*:" config/customize.yaml
Find template sensorsgrep -rB2 "platform: template" config/ --include="*.yaml"
Find groupsgrep -rA5 "^group:" config/ --include="*.yaml"
List domains usedgrep -roh "[a-z_]*\\." config/ --include="*.yaml" | sort -u

评论

支持 Markdown