Home Assistant
Control your smart home from stream with Home Assistant integration for lights, scenes, sensors, and automations.
Overview
FaustBot integrates with Home Assistant to bring smart home control to your stream:
Entity Control
Control any Home Assistant entity.
Scene Activation
Activate pre-configured scenes.
Automations
Trigger automations remotely.
Sensor Monitoring
React to sensor state changes.
Light Control
Color, brightness, and effects.
Climate Control
Temperature and HVAC control.
Setup
Connect Home Assistant
Link FaustBot to your Home Assistant instance using a Long-Lived Access Token.
Create Access Token
In Home Assistant, go to Profile → Long-Lived Access Tokens. Click Create Token and give it a name like "FaustBot". Copy the token immediately - it won't be shown again.
Configure FaustBot
In FaustBot, go to Integrations → Home Assistant. Enter your
Home Assistant URL (e.g., http://homeassistant.local:8123) and
paste your access token.
Connect and Sync
Click Connect. FaustBot will connect and fetch your entities, scenes, and automations. This may take a moment for large installations.
Test the Connection
Try toggling a light or activating a scene to verify the connection works. You should see the change reflected in Home Assistant.
Remote Access
For remote access, use Home Assistant Cloud (Nabu Casa) or set up a secure reverse proxy with HTTPS. Never expose your Home Assistant to the internet without proper security.
Triggers
Respond to Home Assistant events:
Entity State Changed Any entity changed stateSensor Updated Sensor value changedMotion Detected Motion sensor triggeredDoor Opened Door/window sensor triggeredButton Pressed Smart button was pressedAutomation Triggered An automation ranTrigger Variables
These variables are available in your actions:
%haEntityId% Entity ID (e.g., light.living_room)%haEntityName% Friendly name of the entity%haState% New state value%haOldState% Previous state value%haAttributes% Entity attributes as JSON%haDomain% Entity domain (light, switch, etc.)Effects
Entity Control
Turn On
Turn on any entity.
Turn Off
Turn off any entity.
Toggle
Toggle entity state.
Set State
Set entity to specific state.
Light Control
Set Brightness
Adjust light brightness.
Set Color
Change light color.
Set Temperature
Adjust color temperature.
Flash
Flash the light.
Scenes & Automations
Activate Scene
Turn on a scene.
Run Automation
Trigger an automation.
Run Script
Execute a HA script.
Media & Climate
Media Control
Play, pause, volume.
Set Temperature
Adjust thermostat.
Set HVAC Mode
Heat, cool, auto, off.
Scripting API
Control Home Assistant from your scripts:
Entity Control
# Turn on a light
CPH.HomeAssistantTurnOn("light.living_room")
# Turn off with entity
CPH.HomeAssistantTurnOff("switch.fan")
# Toggle a device
CPH.HomeAssistantToggle("light.desk_lamp")
# Get entity state
state = CPH.HomeAssistantGetState("sensor.temperature")
CPH.LogInfo(f"Temperature: {state['state']}°F")Light Control
# Set brightness (0-255)
CPH.HomeAssistantTurnOn("light.studio", brightness=200)
# Set color by RGB
CPH.HomeAssistantTurnOn("light.led_strip", rgb_color=[255, 0, 128])
# Set color by name
CPH.HomeAssistantTurnOn("light.hue_bulb", color_name="purple")
# Set color temperature (mireds)
CPH.HomeAssistantTurnOn("light.desk", color_temp=350)
# Flash the light
CPH.HomeAssistantTurnOn("light.alert", flash="short")
# Transition over time (seconds)
CPH.HomeAssistantTurnOn("light.ambient", brightness=100, transition=5)Scenes & Automations
# Activate a scene
CPH.HomeAssistantActivateScene("scene.stream_mode")
# Turn on scene
CPH.HomeAssistantTurnOn("scene.movie_night")
# Trigger an automation
CPH.HomeAssistantTriggerAutomation("automation.welcome_lights")
# Run a script
CPH.HomeAssistantRunScript("script.party_mode")Service Calls
# Call any Home Assistant service
CPH.HomeAssistantCallService(
domain="notify",
service="mobile_app_phone",
data={
"message": "Stream is live!",
"title": "FaustBot Notification"
}
)
# Climate control
CPH.HomeAssistantCallService(
domain="climate",
service="set_temperature",
entity_id="climate.thermostat",
data={"temperature": 72}
)
# Media player control
CPH.HomeAssistantCallService(
domain="media_player",
service="play_media",
entity_id="media_player.speaker",
data={
"media_content_type": "music",
"media_content_id": "spotify:playlist:xyz"
}
)Chat-Triggered Scenes
# Let viewers control stream lighting
message = CPH.GetArg("message").lower()
scenes = {
"!chill": "scene.chill_mode",
"!hype": "scene.hype_mode",
"!spooky": "scene.spooky_mode",
"!rainbow": "scene.rainbow_party"
}
for command, scene in scenes.items():
if message.startswith(command):
CPH.HomeAssistantTurnOn(scene)
CPH.SendMessage(f"Activated {scene.split('.')[-1].replace('_', ' ')} mode!")
breakSensor Monitoring
# Check room temperature
temp = CPH.HomeAssistantGetState("sensor.room_temperature")
temp_value = float(temp['state'])
if temp_value > 80:
CPH.SendMessage(f"It's getting hot in here! ({temp_value}°F)")
CPH.HomeAssistantTurnOn("switch.fan")
# Check if door is open
door = CPH.HomeAssistantGetState("binary_sensor.front_door")
if door['state'] == "on":
CPH.SendMessage("Warning: Front door is open!")See the full API reference for all available Home Assistant methods.