IoT Tutorial30 min read

Smart Home Control with Moltbot

Your home, voice-controlled. Manage lights, temperature, security, and entertainment through natural chat commands. Works with Philips Hue, Nest, Ring, Sonos, and 100+ smart devices.

Supported Devices

Moltbot integrates with popular smart home platforms and can control virtually any device with an API:

Smart Lights

Hue, LIFX, TP-Link

Climate

Nest, Ecobee, Honeywell

Locks

August, Yale, Schlage

Security

Ring, Arlo, Nest Cam

Media

Samsung, LG, Roku

Audio

Sonos, Bose, Alexa

Appliances

Dyson, iRobot, SwitchBot

Switches

TP-Link, Wemo, Shelly

Natural Language Commands

Control your entire home through simple chat messages:

๐Ÿ‘ค

You

Turn off all lights and set the thermostat to 72 degrees

๐Ÿฆž

Moltbot

โœ… Done! Actions completed:

  • ๐Ÿ’ก Turned off 8 lights (Living room, Kitchen, Hallway)
  • ๐ŸŒก๏ธ Set thermostat to 72ยฐF (was 68ยฐF)
๐Ÿ‘ค

You

Movie time scene

๐Ÿฆž

Moltbot

๐ŸŽฌ Movie scene activated:

  • ๐Ÿ’ก Living room lights dimmed to 20%
  • ๐ŸŒˆ Color set to warm amber
  • ๐Ÿ“บ TV turned on, switched to Netflix
  • ๐Ÿ”‡ Do Not Disturb mode enabled
๐Ÿ‘ค

You

Is the front door locked? Show me the camera feed

๐Ÿฆž

Moltbot

๐Ÿ”’ Front door is UNLOCKED

๐Ÿ“ธ Camera snapshot:

[Front Door Camera Feed]

Reply "lock it" to secure the door.

Setup Guide

1. Home Assistant Integration (Recommended)

Home Assistant is the most popular open-source smart home platform. It supports thousands of devices and has excellent API support.

// Install Home Assistant
// Follow: https://www.home-assistant.io/installation/

// Generate Long-Lived Access Token:
// Profile โ†’ Long-Lived Access Tokens โ†’ Create Token

// ~/.moltbot/moltbot.json
{
  "smartHome": {
    "provider": "homeassistant",
    "url": "http://homeassistant.local:8123",
    "token": "YOUR_LONG_LIVED_TOKEN"
  }
}

2. Device Control Skill

// skills/smart-home.js
module.exports = {
  name: 'smart-home',
  
  async run({ command, config, apis }) {
    const ha = apis.homeassistant;
    
    switch (command.action) {
      case 'turnOn':
        return await ha.callService('light', 'turn_on', {
          entity_id: command.entity
        });
        
      case 'turnOff':
        return await ha.callService('homeassistant', 'turn_off', {
          entity_id: command.entity
        });
        
      case 'setBrightness':
        return await ha.callService('light', 'turn_on', {
          entity_id: command.entity,
          brightness_pct: command.brightness
        });
        
      case 'setTemperature':
        return await ha.callService('climate', 'set_temperature', {
          entity_id: command.entity,
          temperature: command.temperature
        });
        
      case 'activateScene':
        return await ha.callService('scene', 'turn_on', {
          entity_id: `scene.${command.scene}`
        });
        
      case 'getStatus':
        const states = await ha.getStates();
        return states
          .filter(s => s.entity_id.startsWith(command.domain))
          .map(s => ({
            entity: s.entity_id,
            state: s.state,
            attributes: s.attributes
          }));
    }
  }
};

3. Scene Definitions

// skills/scenes.js
module.exports = {
  name: 'scenes',
  
  scenes: {
    'morning': {
      description: 'Good morning routine',
      actions: [
        { service: 'light.turn_on', entity: 'light.bedroom', brightness: 50, color: 'warm' },
        { service: 'climate.set_temperature', entity: 'climate.living_room', temperature: 72 },
        { service: 'media_player.play_media', entity: 'media_player.bedroom_speaker', media: 'morning_playlist' },
        { service: 'cover.open_cover', entity: 'cover.bedroom_blinds' }
      ]
    },
    
    'leaving_home': {
      description: 'Leaving home - secure everything',
      actions: [
        { service: 'light.turn_off', entity: 'all' },
        { service: 'climate.set_away_mode', entity: 'climate.living_room', away: true },
        { service: 'lock.lock', entity: 'lock.front_door' },
        { service: 'alarm_control_panel.alarm_arm_away', entity: 'alarm.home' }
      ]
    },
    
    'movie_time': {
      description: 'Dim lights for movie watching',
      actions: [
        { service: 'light.turn_on', entity: 'light.living_room', brightness: 20, color: 'amber' },
        { service: 'switch.turn_on', entity: 'switch.tv_bias_lighting' },
        { service: 'media_player.select_source', entity: 'media_player.tv', source: 'Netflix' }
      ]
    }
  }
};

4. Voice Command Parser

// Natural language to smart home commands
async function parseCommand(message) {
  const lower = message.toLowerCase();
  
  // Scene activation
  if (lower.includes('movie time')) {
    return { action: 'activateScene', scene: 'movie_time' };
  }
  
  // Light control
  if (lower.match(/turn (on|off).*(light|lamp)/)) {
    const turnOn = lower.includes('on');
    const room = extractRoom(lower);
    return {
      action: turnOn ? 'turnOn' : 'turnOff',
      entity: `light.${room}`
    };
  }
  
  // Temperature control
  if (lower.match(/set.*temp|thermostat/)) {
    const temp = extractNumber(lower);
    return {
      action: 'setTemperature',
      entity: 'climate.living_room',
      temperature: temp
    };
  }
  
  // Status queries
  if (lower.match(/is.*locked|status of/)) {
    const device = extractDevice(lower);
    return {
      action: 'getStatus',
      domain: device
    };
  }
}

Smart Automation Ideas

Sunrise Simulation

Gradually brighten bedroom lights 30 minutes before alarm. Open blinds when alarm sounds.

Presence Detection

Turn off all devices when everyone leaves. Turn on welcome lights when someone arrives.

Security Monitoring

Get WhatsApp alerts with camera snapshots when motion detected while away.

Energy Saving

Automatically adjust thermostat based on weather. Turn off devices in unused rooms.

Smart Home Platforms

PlatformBest ForDifficultyCost
Home AssistantPower users, privacy-focusedMediumFree (hardware ~$100)
HubitatLocal control, no cloudMedium$150 (one-time)
SmartThingsBeginners, Samsung ecosystemEasy$100 (hub)
Apple HomeKitApple users, Siri integrationEasyFree (Apple TV/HomePod)

Security Best Practices

  • Use strong, unique tokens for API access
  • Enable two-factor authentication on all accounts
  • Keep smart home devices on a separate VLAN
  • Regular firmware updates for all devices
  • Review and restrict device permissions

Control Your Home with Voice

Transform your house into a smart home. Control everything from lights to locks with simple chat commands.