| Network | Dedicated IoT VLAN | Standard WiFi |
Initial Configuration
# config.yaml
agent:
system_prompt: |
You are a smart home controller. You manage devices in these rooms:
- Living Room: lights (ceiling, lamp), TV, speakers, thermostat
- Bedroom: lights (main, bedside), blinds, fan
- Kitchen: lights, coffee machine, oven status sensor
- Office: lights, monitor, desk fan
- Bathroom: lights, heated floor, ventilation
Device naming convention: {type}.{room}_{device}
Example: light.living_room_ceiling
Rules:
- Always confirm before locking doors or arming alarm
- Never set thermostat below 16°C or above 28°C
- Dim lights gradually (not instant) after 10 PM
- Report energy usage when asked
Room-Based Scenes
// skills/home-scenes/index.js
const scenes = {
"morning": {
description: "Gentle wake-up routine",
actions: [
{ entity: "cover.bedroom_blinds", action: "open", delay: 0 },
{ entity: "light.bedroom_main", action: "turn_on", attrs: { brightness: 30, color_temp: 300 }, delay: 0 },
{ entity: "light.bedroom_main", action: "turn_on", attrs: { brightness: 80, color_temp: 250 }, delay: 300000 }, // 5 min later
{ entity: "climate.home", action: "set", attrs: { temperature: 22 }, delay: 0 },
{ entity: "switch.coffee_machine", action: "turn_on", delay: 600000 } // 10 min later
]
},
"movie_night": {
description: "Cinema experience at home",
actions: [
{ entity: "light.living_room_ceiling", action: "turn_off" },
{ entity: "light.living_room_lamp", action: "turn_on", attrs: { brightness: 10, rgb_color: [255, 147, 41] } },
{ entity: "cover.living_room_blinds", action: "close" },
{ entity: "media_player.living_room_tv", action: "turn_on" },
{ entity: "media_player.living_room_speakers", action: "turn_on" }
]
},
"goodnight": {
description: "Secure the house and prepare for sleep",
actions: [
{ entity: "light.all", action: "turn_off" },
{ entity: "lock.front_door", action: "lock" },
{ entity: "lock.back_door", action: "lock" },
{ entity: "cover.all", action: "close" },
{ entity: "alarm.home", action: "arm_night" },
{ entity: "climate.home", action: "set", attrs: { temperature: 19 } }
]
},
"away": {
description: "Leaving the house",
actions: [
{ entity: "light.all", action: "turn_off" },
{ entity: "climate.home", action: "set", attrs: { temperature: 17 } },
{ entity: "lock.all", action: "lock" },
{ entity: "alarm.home", action: "arm_away" },
{ entity: "switch.random_lights", action: "turn_on" } // Presence simulation
]
}
};
module.exports = {
name: "home-scenes",
tools: [
{
name: "activate_scene",
description: "Activate a predefined home scene",
parameters: {
type: "object",
properties: {
scene_name: {
type: "string",
enum: Object.keys(scenes)
}
},
required: ["scene_name"]
},
async execute({ scene_name }, context) {
const scene = scenes[scene_name];
if (!scene) return { error: "Unknown scene" };
for (const action of scene.actions) {
if (action.delay > 0) {
setTimeout(() => executeAction(action, context), action.delay);
} else {
await executeAction(action, context);
}
}
return { activated: scene_name, description: scene.description };
}
}
]
};
Energy Monitoring
// skills/energy-monitor/index.js
module.exports = {
name: "energy-monitor",
tools: [
{
name: "energy_report",
description: "Get energy usage report",
parameters: {
type: "object",
properties: {
period: { type: "string", enum: ["today", "week", "month"] }
}
},
async execute({ period = "today" }, context) {
const sensors = await context.homeAssistant.getStates("sensor.energy_*");
return {
total_kwh: sensors.reduce((sum, s) => sum + parseFloat(s.state), 0),
by_device: sensors.map(s => ({
name: s.attributes.friendly_name,
kwh: parseFloat(s.state),
cost: (parseFloat(s.state) * 0.30).toFixed(2)
})),
period
};
}
}
]
};
Conditional Automation
# Automations triggered by context
automations:
- name: "Weather-based blinds"
trigger: "temperature > 25°C AND sun_elevation > 30"
action: "Close south-facing blinds"
- name: "Presence-based lighting"
trigger: "motion detected AND time between sunset and 23:00"
action: "Turn on room lights at 60% brightness"
- name: "Energy saver"
trigger: "no motion for 30 minutes in a room"
action: "Turn off lights and reduce heating in that room"
- name: "Security alert"
trigger: "door/window opened AND alarm armed"
action: "Send notification, activate cameras, turn on all lights"
Voice + Text Control Examples