Entity Renameのロゴ

Entity Rename

コミュニティ
dcb
entity-rename

Batch rename Home Assistant entities to follow a consistent naming convention. Discovers entities, proposes renames, executes via HA API, and updates all YAML/TypeScript references automatically. Trigger phrases: "rename entities", "fix entity names", "standardize entity IDs", "entity rename", "clean up names".

概要

公開者dcb
リポジトリhomeassistant-claude-kit
スキル名entity-rename
スター
125
フォーク
22
同梱ファイル
1
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    dcbがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルEntity RenameをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/dcb/homeassistant-claude-kit/tree/main/.claude/skills/entity-rename
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dcb/homeassistant-claude-kit.git /tmp/homeassistant-claude-kit
mkdir -p .claude/skills
cp -r /tmp/homeassistant-claude-kit/.claude/skills/entity-rename .claude/skills/entity-rename
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでEntity Renameを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にEntity Renameを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Entity Renameは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Entity Rename Skill

Rename Home Assistant entities to follow a consistent domain.{room}_{descriptor} convention. Updates all YAML automations, scripts, dashboard code, and .storage/ configs automatically.

See references/naming-convention.md for the full naming convention. See docs/solutions/tooling/entity-rename-lessons.md for safety rules from production use.

Step 0: Prerequisites

Verify the environment is ready:

bash
# Check .env exists with HA connection
test -f .env && grep -q HA_TOKEN .env && echo "ENV_OK" || echo "ENV_MISSING"

# Check entity registry exists (needs make pull first)
test -f config/.storage/core.entity_registry && echo "REGISTRY_OK" || echo "REGISTRY_MISSING"

# Check ha-ws is available on HA instance
source .env 2>/dev/null
ssh "$SSH_USER@$HA_HOST" "command -v ha-ws" >/dev/null 2>&1 && echo "HAWS_OK" || echo "HAWS_MISSING"
  • ENV_MISSING: Tell user to run setup-infrastructure first or create .env manually.
  • REGISTRY_MISSING: Tell user to run make pull first.
  • HAWS_MISSING: Install claude-code-ha on the HA instance:
    bash
    ssh "$SSH_USER@$HA_HOST" "bash ${HA_REMOTE_PATH}claude-code-ha/install.sh"
    See danbuhler/claude-code-ha. Provides ha-api (REST) and ha-ws (WebSocket) CLI tools that run directly on HA.

Step 1: Discovery

Parse local registry files to build a complete entity inventory:

bash
source venv/bin/activate
python tools/entity_explorer.py config/ --full

This uses the device registry join (entity.device_id -> device.area_id) to resolve areas for entities that don't have a direct area_id.

Present the inventory to the user grouped by area/room:

  • Show entity count per area
  • Highlight entities that don't follow the naming convention
  • Flag entities with serial numbers, product names, or non-English names

Step 2: Convention Proposal

For each non-conforming entity, propose a new name following references/naming-convention.md.

Present renames grouped by room. For each room, show:

Living Room (12 entities to rename):
  climate.jch_8862dcd1     -> climate.living_room_ac
  light.hue_ambiance_spot_1 -> light.living_room_spot_1
  ...
  [Approve all] [Edit] [Skip room]

Before proposing each rename:

  1. Verify target entity_id doesn't already exist (safety rule 3)
  2. Detect name collisions requiring two-step renames (safety rule 4)
  3. For each device, enumerate ALL child entities (safety rule 2):
    • battery, calibration, heating, window_detection, anti_scaling, etc.
    • Use device_id from entity registry to find siblings

Save approved renames to a JSON file for batch execution:

bash
# Write to entity-renames.json (or a temp batch file)
python3 -c "
import json
renames = [
    {'old_id': 'climate.jch_8862dcd1', 'new_id': 'climate.living_room_ac'},
    ...
]
with open('rename_batch.json', 'w') as f:
    json.dump(renames, f, indent=2)
"

Step 3: Reference Scanning

Before executing, scan for all references to understand the blast radius:

bash
source venv/bin/activate
python tools/update_yaml_refs.py rename_batch.json --dry-run

This shows which files reference each old entity ID and how many replacements would be made. Present the summary to the user:

climate.jch_8862dcd1: 34 references across 5 files
  config/automations/climate.yaml: 18 refs
  config/scripts/climate.yaml: 8 refs
  config/configuration.yaml: 4 refs
  dashboard/src/lib/entities.ts: 2 refs
  config/automations.yaml: 2 refs

Step 4: Batch Execution

Execute renames in batches, grouped by room. For EACH batch:

4a. Rename entities on HA

Primary (ha-ws via SSH):

bash
# Rename a single entity
ssh "$SSH_USER@$HA_HOST" "source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH:=/config/}.env; ha-ws entity update sensor.old_name new_entity_id=sensor.new_name"

# Batch rename from a file
cat rename_batch.json | python3 -c "
import json, sys, subprocess
for r in json.load(sys.stdin):
    cmd = f'ha-ws entity update {r[\"old_id\"]} new_entity_id={r[\"new_id\"]}'
    print(f'Renaming: {r[\"old_id\"]} -> {r[\"new_id\"]}')
    subprocess.run(['ssh', '$HA_HOST', f'source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH:=/config/}.env; {cmd}'])
"

Alternative (Python script with WebSocket fallback):

bash
source venv/bin/activate
python tools/entity_rename.py rename_batch.json

Only needed if SSH is unavailable. The script connects directly via WebSocket.

4b. Update all YAML/TypeScript references locally

bash
python tools/update_yaml_refs.py rename_batch.json

4c. Check for .storage/ files that need patching

If any renamed entities are in Adaptive Lighting zones, patch the zone config on HA via SSH:

bash
# Back up first (safety rule 10)
ssh "$SSH_USER@$HA_HOST" "cp ${HA_REMOTE_PATH}.storage/core.config_entries ${HA_REMOTE_PATH}.storage/core.config_entries.bak"

# Patch AL zone lights arrays
ssh "$SSH_USER@$HA_HOST" "python3 -c \"
import json
with open('${HA_REMOTE_PATH}.storage/core.config_entries') as f:
    data = json.load(f)
for entry in data.get('data', {}).get('entries', []):
    if entry.get('domain') == 'adaptive_lighting':
        opts = entry.get('options', {})
        lights = opts.get('lights', [])
        # Replace old IDs with new IDs
        opts['lights'] = [MAPPING.get(l, l) for l in lights]
with open('${HA_REMOTE_PATH}.storage/core.config_entries', 'w') as f:
    json.dump(data, f, indent=2)
print('AL zones patched')
\""

4d. Record in tracker

Append batch results to entity-renames.json:

python
import json, datetime
with open('entity-renames.json') as f:
    tracker = json.load(f)
for rename in batch:
    tracker['renames'].append({
        'batch': batch_number,
        'date': datetime.date.today().isoformat(),
        'old_id': rename['old_id'],
        'new_id': rename['new_id'],
        'references_updated': rename.get('ref_count', 0),
    })
with open('entity-renames.json', 'w') as f:
    json.dump(tracker, f, indent=2)

4e. Validate (CRITICAL — after EVERY batch)

bash
# Sync updated registry from HA
make pull

# Validate YAML references
make validate

# Grep for any remaining old entity IDs
for old_id in $(python3 -c "import json; [print(r['old_id']) for r in json.load(open('rename_batch.json'))]"); do
    echo "Checking: $old_id"
    grep -rn "$old_id" config/ dashboard/src/ || echo "  Clean"
done

If validation fails or old IDs remain, fix them before proceeding to the next batch.

Step 5: Verification and Cleanup

After all batches complete:

  1. Run make push to deploy updated YAML to HA
  2. If AL zones were patched: restart HA (reload is not enough — safety rule 8)
  3. Run make validate one final time
  4. Reload automations: ssh "$SSH_USER@$HA_HOST" "source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH:=/config/}.env; ha-api call automation reload"
  5. Check a few automations in the HA UI to verify they work with the new entity IDs

Resume Support

If the conversation ends mid-rename:

  • entity-renames.json tracks which renames have been completed
  • On resume, read the tracker and skip already-completed renames
  • The batch JSON file records the full plan; compare against tracker to find remaining work

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Entity Rename」では何ができますか?

Batch rename Home Assistant entities to follow a consistent naming convention. Discovers entities, proposes renames, executes via HA API, and updates all YAML/TypeScript references automatically. Trigger phrases: "rename entities", "fix entity names", "standardize entity IDs", "entity rename", "clean up names".

TypingMindでEntity Renameを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Entity Renameはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにEntity Renameをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/dcb/homeassistant-claude-kit/tree/main/.claude/skills/entity-renameを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Entity Renameを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Entity Renameは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもEntity Renameを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Entity Rename」は無料ですか?

はい。dcbがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇