Skip to content

feat: Add Home Assistant smart device integration (Issue #366) - #2435

Open
Wanbogang wants to merge 5 commits into
OpenMind:mainfrom
Wanbogang:feature/home-assistant-integration
Open

feat: Add Home Assistant smart device integration (Issue #366)#2435
Wanbogang wants to merge 5 commits into
OpenMind:mainfrom
Wanbogang:feature/home-assistant-integration

Conversation

@Wanbogang

@Wanbogang Wanbogang commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements Home Assistant smart device integration, allowing OM1 robots to control smart home devices via Home Assistant. #366

Changes

New: src/actions/home_assistant/

  • interface.py — defines HADeviceType, HAAction, HomeAssistantInput, and shared COLOR_MAP
  • connector/rest_api.py — REST API connector
  • connector/websocket.py — WebSocket connector
  • connector/mqtt.py — MQTT connector

Each connector supports:

  • Light: turn on/off, set brightness, set color
  • Switch: turn on/off
  • Climate: set temperature, turn on/off

New: src/inputs/plugins/home_assistant.py

  • HomeAssistantStateInput plugin for real-time device state monitoring via REST polling

New: config/home_assistant.json5

  • Example configuration file for Home Assistant integration

Updated: pyproject.toml

  • Added aiomqtt==2.5.0 dependency for MQTT connector

- Add home_assistant action with 3 connectors:
  - REST API (rest_api.py)
  - WebSocket (websocket.py)
  - MQTT (mqtt.py)
- Each connector supports:
  - Light (on/off, brightness, color)
  - Switch (on/off)
  - Climate/thermostat (temperature, on/off)
- Add HomeAssistantStateInput plugin for real-time device state monitoring
- Add config/home_assistant.json5 example configuration
- Add aiomqtt==2.5.0 dependency
- Add 125 unit tests, all passing at 100% coverage
- Ruff and pyright clean

Follows OM1 action/input plugin architecture conventions.
@Wanbogang
Wanbogang requested review from a team as code owners March 1, 2026 04:25
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file robotics Robotics code changes python Python code tests Test files config Configuration files labels Mar 1, 2026
@codecov

codecov Bot commented Mar 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@Prachi1615

Copy link
Copy Markdown
Collaborator

Hi @Wanbogang
Do you have a demo video showcasing the working of this?

Wanbogang added 2 commits June 1, 2026 11:35
The LLM may emit empty-string values for optional numeric fields
(brightness, temperature) when they are not relevant to the chosen
action (e.g. turn_on). The orchestrator's blind int()/float() cast
then raised ValueError: invalid literal for int() with base 10: ''.

Change brightness/temperature to str in the interface and convert
them safely inside each connector (rest_api, mqtt, websocket),
falling back to sane defaults on empty/invalid input. Tests updated
accordingly. Add aiomqtt to uv.lock for the MQTT connector.
@Wanbogang

Copy link
Copy Markdown
Contributor Author

Hi @Prachi1615
thanks for reviewing!

I don't have a recorded video at the moment (screen recording is glitchy on my setup), but I tested the integration end-to-end against a real Home Assistant instance (HA running in Docker with the demo platform providing virtual light/switch/climate entities). I'm attaching screenshots below that walk through the full pipeline.

Setup: OM1 running the home_assistant config, connected to HA via the REST connector using a long-lived token. Commands are sent to the agent, the LLM decides the home_assistant action, and the connector calls the HA REST API.

What the screenshots show:

  1. Turn on — voice command "turn on the bed light" → agent calls home_assistant(action=turn_on, entity_id=light.bed_light)HomeAssistantRESTConnector: success 200.
  2. Set brightness — "set brightness to 30%" → agent calls set_brightness (LLM maps to brightness 77/255) → success 200.
  3. Turn off + HA Logbook showing every action recorded as "Bed Light turned on/off triggered by action Light" with timestamps.

The HomeAssistantStateInput plugin also picks up the state changes back into the agent (e.g. "Bed Light (light.bed_light) is on, brightness 30%"), so the loop is bidirectional.

One extra thing I found while testing: when the LLM emits empty-string values for optional numeric params (brightness/temperature) on a plain turn_on, the orchestrator's int()/float() cast raised ValueError: invalid literal for int(). I pushed a fix (commit 81a8f00) that changes those params to str in the interface and converts them safely inside each connector (rest_api, mqtt, websocket) with sane fallbacks. All 125 tests pass.

I can record a proper video once I sort out the screen-recording issue on my machine — let me know if the screenshots are enough for now. Thanks!

Screenshot from 2026-06-01 13-57-12 Screenshot from 2026-06-01 13-59-29 Screenshot from 2026-06-01 14-00-11 Screenshot from 2026-06-01 14-00-43 Screenshot from 2026-06-01 14-01-01

@Prachi1615

Copy link
Copy Markdown
Collaborator

Hi @Wanbogang
Thanks for the screen grabs.
Can you migrate your implementation to Go and sync with current codebase?
The python version is no longer being maintained!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration files dependencies Pull requests that update a dependency file python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants