setup-customize
Run after setup-infrastructure to map rooms, entities, and preferences to the dashboard and automation templates. Conversational and resumable. Trigger phrases: "customize my home", "set up rooms", "configure automations", "map my entities", "set up my dashboard", "finish setup", "resume setup".
dcb · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add dcb/homeassistant-claude-kit --skill setup-customize技能说明
name: setup-customize description: > Run after setup-infrastructure to map rooms, entities, and preferences to the dashboard and automation templates. Conversational and resumable. Trigger phrases: "customize my home", "set up rooms", "configure automations", "map my entities", "set up my dashboard", "finish setup", "resume setup".
Setup Customize
This skill maps your Home Assistant instance to the dashboard and automation templates through a guided interview. It is resumable — if the conversation ends mid-way, re-invoke this skill and it will pick up from the last checkpoint.
See references/question-patterns.md for detailed question wording and example answers
for each domain.
Step 0: Check Prerequisites
Verify setup-state.json exists and infrastructure is complete:
import json, sys, os
if not os.path.exists('setup-state.json'):
print('NOT_READY'); sys.exit(0)
with open('setup-state.json') as f:
state = json.load(f)
schema = state.get('schema_version', 0)
if schema > 1:
print('SCHEMA_WARNING')
phase = state.get('session', {}).get('current_phase', '')
infra = state.get('infrastructure', {}).get('steps_completed', [])
if 'infrastructure_complete' in phase or 'pull' in infra:
answers = state.get('answers', {})
if answers.get('rooms') or phase.startswith('customize:'):
print('RESUME')
print(f'PHASE:{phase}')
print(f'ROOMS_DONE:{",".join(answers.get("rooms", {}).keys())}')
else:
print('FRESH')
else:
print('NOT_READY')
Run via python3 -c "..." and check the output:
NOT_READY: Tell user to runsetup-infrastructurefirst.SCHEMA_WARNING: State file from newer version — proceed with caution.RESUME: Load checkpoint. Tell user: "Welcome back! You were at [phase]. Rooms done: [list]. Continuing."FRESH: Begin from Phase 1.
Checkpoint Writing Pattern
After EVERY user answer, update setup-state.json with granular progress:
import json
def save_checkpoint(phase, answers_update=None, files_written=None):
with open('setup-state.json') as f:
state = json.load(f)
state['session']['current_phase'] = phase
if answers_update:
state.setdefault('answers', {}).update(answers_update)
if files_written:
state.setdefault('files_written', []).extend(files_written)
with open('setup-state.json', 'w') as f:
json.dump(state, f, indent=2)
Example calls:
save_checkpoint('customize:room_mapping', {'rooms': {'living_room': {'light': '...', 'motion': '...'}}})save_checkpoint('customize:domain_selection', {'domains_selected': ['lighting', 'climate']})save_checkpoint('customize:notifications', {'notify_targets': {'primary': 'notify.mobile_app_x'}})save_checkpoint('customize:files', files_written=['config/automations/lighting.yaml'])
Step 1: Discover Entity + Area + Floor Registries
Primary method: Use registry data. Entity-to-room assignment should come from the
device/entity registries (via area_id) whenever possible. This is the authoritative source.
Fallback: Name inference + user confirmation. If the registries have sparse area
assignments (common in setups where the user hasn't organized areas in HA), you may infer
room assignments from entity ID naming patterns (e.g., bedroom_motion → bedroom).
However, when using name inference, you MUST:
- Clearly mark inferred assignments as "inferred (not in registry)"
- Ask the user to confirm ALL inferred assignments before proceeding
- Never present inferred data as verified fact
1a. Query Floor + Area Registries
Get the authoritative room and floor structure:
source .env && ssh "$SSH_USER@$HA_HOST" "source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH:=/config/}.env; ha-ws raw config/floor_registry/list" 2>/dev/null
source .env && ssh "$SSH_USER@$HA_HOST" "source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH}.env; ha-ws raw config/area_registry/list" 2>/dev/null
This gives you:
- All floors with IDs and names
- All areas with
floor_idassignments - Do NOT ask the user about floors if this data is available.
1b. Query Device + Entity Registries
Get the authoritative entity-to-area mappings:
source .env && ssh "$SSH_USER@$HA_HOST" "source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH}.env; ha-ws raw config/device_registry/list" 2>/dev/null
source .env && ssh "$SSH_USER@$HA_HOST" "source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH}.env; ha-ws raw config/entity_registry/list" 2>/dev/null
Entity-to-area resolution chain:
- Check
entity_registry→ if the entity has a directarea_id, use it - Otherwise, find the entity's
device_id→ look up that device indevice_registry→ use the device'sarea_id - If neither has an
area_id, the entity is unassigned — note it but do NOT guess
1c. Query Entities by Domain
For each relevant domain, query the live entity list:
source .env
for domain in light binary_sensor sensor climate media_player camera cover vacuum remote switch; do
ssh "$SSH_USER@$HA_HOST" "source /etc/profile.d/claude-ha.sh; source ${HA_REMOTE_PATH}.env; ha-ws entity list $domain" 2>/dev/null
done
1d. Build Verified Room-Entity Map
Cross-reference the entity list with the device/entity registry area assignments to build a verified mapping. For each room, list:
- Lights (prefer zone/group entities over individual bulbs)
- Motion sensors (
binary_sensor.*withdevice_class: motionoroccupancy) - Temperature sensors
- Climate entities (TRVs, AC units)
- Media players
- Cameras
Before presenting any mapping to the user: mark each assignment's source:
- Registry: directly from device/entity registry
area_id— present as fact - Inferred: from entity ID naming pattern — present with a
?mark, ask user to confirm - Unassigned: no area in registry and no clear naming pattern — ask t