OpenClawHomeAssistant icon indicating copy to clipboard operation
OpenClawHomeAssistant copied to clipboard

[Chat] General discussions and tweaks

Open techartdev opened this issue 10 months ago • 15 comments

This issue will be used for general talk about possible improvements and small tweaks. For problems and bugs, please open new issue.

techartdev avatar Feb 03 '26 22:02 techartdev

Hey @techartdev - thanks for your hard work 💪

I was thinking today that it would be great to bind additional volumes/folders from the HAOS host machine directly to the addon container. Would it be possible to consider adding such option to the addon settings? I would like to give direct access to homeassistant files for development purposes. Network shares or ssh is an option, but it's a hassle on its own to setup. MCP for HA exists, but it is quite limited and excludes file access.

After all this is a HA addon, so it would be logical to have direct deep integration to HA out of the box? 😅

Thoughts?

lazmo88 avatar Feb 04 '26 01:02 lazmo88

Hey, @techartdev. Could you explain how to set the Gateway Web UI URL? I do have NabuCasa for cloud support and I know my nabu.casa base URL. What do I append to it to load the Web UI? Is it {something}.ui.nabu.casa:PORT or something else?

FinallyCanuck avatar Feb 04 '26 02:02 FinallyCanuck

Does anyone knows how to bind a Ollama instance from a different PC? I have a machine dedicated only to Ollama but not able to connect it.

Any help would be truly appreciated.

camilo-sx avatar Feb 04 '26 06:02 camilo-sx

Hey guys!

@lazmo88 Well I easily solve this on my end by installing the Samba addon for Home Assistant. Then I can reach the file system in my network. Addon data can be found under addon_configurations folder. There you will see folder including openclaw in the name. This space is persisted during updates, image rebuilds and so on. Inside the addon openclaw folder I have dev folder where I store GitHub repos and other dev related stuff like scripts. This way I can map it as network drive on my PC and reach it very easy. You can modify the openclaw config files or the memory, skills etc manually. If you want OpenClaw to access other paths then yes, I will consider what we can do.

@FinallyCanuck First of all I'm not advising you to do that. The Gateway may not be secure to be public. OpenClaw is very new and can contain undiscovered vulnerabilities. Second, I'm not sure does Nabu Casa actually supports that at all. Probably doesn't. Much better is to use Tailscale, CloudFlare tunnel (if you own domain) or private VPN. With VPN for example you will need to put the url as IP:port. In Tailscale you will be provided with unique sub domain and again set it url:port. Your OpenClaw bot can actually help you if you ask him.

@camilo-sx yes, I was able to. At the moment I use LMStudio but it is pretty much the same. In my case I just asked OpenClaw to set it for me. Make sure on the host where ollama runs that you opened the proper ports in the firewall. OpenClaw supports ollama as model integration and you can easily configure it by running in terminal: openclaw configure --section models. Skip first list of popular providers, then you will be presented with larger list that should include ollama. I am trying to remember but I think ollama had configuration to enable the API so it starts exposing the model out of the app itself. Then open firewall, then configure OpenClaw to use it. https://thenewstack.io/connect-to-a-local-ollama-ai-instance-from-within-your-lan/

techartdev avatar Feb 04 '26 08:02 techartdev

in the latest upate, but still getting error with rasperry pi.

Install missing skill dependencies │ 🔐 1password │ ◇ Install failed: 1password (exit 1) — Error: Failure while executing; /usr/bin/env PATH=/home/linuxbrew/.linuxbrew/opt/unzip/bin:/home/linuxbrew/.linuxbrew/Homebrew/Library/Hom… Error: Failure while executing; /usr/bin/env PATH=/home/linuxbrew/.linuxbrew/opt/unzip/bin:/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/shared:/usr/bin:/bin:/usr/sbin:/sbin unzip -qq -o /config/.cache/Homebrew/downloads/77f843f41b105935caef51c10df4ad9eccbc0151f292e38b188444e33e5f4c07--op_linux_arm64_v2.32.0.zip -d /var/tmp/homebrew-unpack-20260204-186-gqffanexited with 127. Here's the output: /usr/bin/env: ‘unzip’: No such file or directory Tip: runopenclaw doctor` to review skills + requirements. Docs: https://docs.openclaw.ai/skills

boo3dmax avatar Feb 04 '26 14:02 boo3dmax

After install i get a 404 attempting to open terminal. Log has error with port binding. [2026/02/04 16:29:01:4748] E: [null wsi]: lws_socket_bind: ERROR on binding fd 13 to port 7681 (-1 98)

is the port "fixed" to 7681?

gmarblestoneCegal avatar Feb 04 '26 14:02 gmarblestoneCegal

@gmarblestoneCegal Hi! Did you managed to find out what is using the port? Or it is a service that runs on other addon. Because the error means it conflicts, the port is already open. Did you tried to restart the OpenClaw Add-On?

techartdev avatar Feb 04 '26 14:02 techartdev

@techartdev yes i restarted and no, i'm not sure what could be using the port. Because this is ingress i'd assume nothing? Even when i set the configuration to enable_terminal: false the log still gives the log message "Starting web terminal (ttyd) on 127.0.0.1:7681 ..." so it would seem somehow mine isn't listening to the configuration either.

thanks for developing ...

gmarblestoneCegal avatar Feb 04 '26 15:02 gmarblestoneCegal

@gmarblestoneCegal Alright, thanks for the feedback!

This PR https://github.com/techartdev/OpenClawHomeAssistant/pull/28 should fix it for you. I've added a kill when Add-On starts, so if our web terminal is stuck for some reason will destroy the instance. Also I added a config option to change the port of the terminal, so if a service conflicts with it you can pick different one. I'll wait for Copilot review and merge it. Already tested on dev repo and works on my test HA device.

Edit: Version 0.5.34 is now released and contains the changes mentioned above

techartdev avatar Feb 05 '26 08:02 techartdev

Resolved

gmarblestoneCegal avatar Feb 11 '26 15:02 gmarblestoneCegal

I think it will be very interesting to allow the bot to read my homeassistant logbook, so that the bot can get information about my daily routine and activity.

Archeb avatar Feb 11 '26 18:02 Archeb

@Archeb It is actually possible but you have to provide long-lived token to the bot, issued by your HA account. But you should be careful, this token gives full access to the whole HA API so he can read everything. If you use lots of community skills, run the bot to online sites or bloat spaces like molthub I do not advice you to do it, as your bot is already exposed on risk. If you do not do any of these you can try. I gave mine HA admin access from day 1.

techartdev avatar Feb 12 '26 11:02 techartdev

Yes I have implemented this using a long-lived token and made a skill:

---
name: home-log
description: Get historical logbook entries from Home Assistant for a specific time range to analyze device states and events.
version: 1.0.0
license: Apache-2.0
---

# Home Assistant Logbook Access

This skill allows you to retrieve historical event logs from a Home Assistant instance. It is useful for checking if lights were left on, seeing who opened a door, or debugging automation triggers.

## Prerequisites

The environment must have the following variables set:
- `HA_URL`: The base URL of the Home Assistant instance (e.g., [http://192.168.1.5:8123](http://192.168.1.5:8123)).
- `HA_TOKEN`: A Long-Lived Access Token.

## How to use

To fetch the logbook, you should execute the python script located at `scripts/run.py` within this skill's directory.

### Command Syntax

```bash
python3 scripts/run.py --start_time <ISO8601_TIME> [options]
```

### Parameters

| Argument | Required | Description | Example |
| :--- | :--- | :--- | :--- |
| `--start_time` | **Yes** | The start of the query window in ISO 8601 format. | `2023-10-27T08:00:00+08:00` |
| `--end_time` | No | The end of the query window in ISO 8601 format. | `2023-10-27T09:00:00+08:00` |
| `--entity_id` | No | Filter logs to a specific entity ID. Highly recommended to reduce noise. | `light.living_room` |

### Examples

**Check a specific light for the last 30 minutes:**
If the current time is 10:00, check from 09:30:
```bash
python3 scripts/run.py --start_time "2023-10-27T09:30:00+08:00" --entity_id "light.living_room"
```

**Check all events in a specific window:**
```bash
python3 scripts/run.py --start_time "2023-10-27T08:00:00+08:00" --end_time "2023-10-27T08:15:00+08:00"
```
#!/usr/bin/env python3
import sys
import json
import os
import argparse

def final_output(data):
    print(json.dumps(data, ensure_ascii=False, indent=2))
    sys.exit(0)

def error_output(error_type, message, details=None):
    payload = {
        "status": "error",
        "error_type": error_type,
        "message": message
    }
    if details:
        payload["details"] = str(details)
    final_output(payload)

try:
    import requests
except ImportError:
    error_output("DependencyMissing", "Python module 'requests' is not installed.", "Run: pip install requests")

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--start_time", required=True)
    parser.add_argument("--end_time", required=False)
    parser.add_argument("--entity_id", required=False)
    
    try:
        args = parser.parse_args()
    except SystemExit:
        sys.exit(1)

    base_url = os.getenv("HA_URL")
    token = os.getenv("HA_TOKEN")
    
    missing_vars = []
    if not base_url: missing_vars.append("HA_URL")
    if not token: missing_vars.append("HA_TOKEN")
    
    if missing_vars:
        error_output("ConfigurationError", f"Missing environment variables: {', '.join(missing_vars)}")

    headers = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json",
    }
    
    clean_url = base_url.rstrip('/')
    api_url = f"{clean_url}/api/logbook/{args.start_time}"
    
    params = {}
    if args.end_time: params["end_time"] = args.end_time
    if args.entity_id: params["entity"] = args.entity_id

    try:
        response = requests.get(api_url, headers=headers, params=params, timeout=10)
        
        if response.status_code != 200:
            try:
                err_body = response.json()
            except:
                err_body = response.text[:200]
            
            error_output("HttpError", f"Home Assistant returned {response.status_code}", err_body)

        try:
            data = response.json()
        except json.JSONDecodeError:
            error_output("ParseError", "Response was not valid JSON", response.text[:200])

        if isinstance(data, list) and len(data) == 0:
            final_output({
                "status": "success",
                "count": 0,
                "logs": [],
                "message": "No log entries found for this time range."
            })

        MAX_ENTRIES = 50
        clean_logs = []
        
        if isinstance(data, list):
            for entry in data[:MAX_ENTRIES]:
                clean_logs.append({
                    "time": entry.get("when"),
                    "name": entry.get("name"),
                    "state": entry.get("state"),
                    "message": entry.get("message")
                })
        else:
             error_output("UnexpectedFormat", "API returned data that is not a list", str(data))

        result = {
            "status": "success",
            "count": len(clean_logs),
            "total_found": len(data),
            "logs": clean_logs
        }
        
        if len(data) > MAX_ENTRIES:
            result["warning"] = f"Result truncated. Showing first {MAX_ENTRIES} of {len(data)} entries."

        final_output(result)

    except requests.exceptions.Timeout:
        error_output("NetworkError", "Request timed out (10s)", f"Connecting to {clean_url}")
    except requests.exceptions.ConnectionError:
        error_output("NetworkError", "Connection refused or DNS failure", f"Check if {clean_url} is reachable")
    except requests.exceptions.RequestException as e:
        error_output("NetworkError", "General request failure", str(e))
    except Exception as e:
        error_output("UnexpectedError", "An unhandled error occurred in logic", str(e))

if __name__ == "__main__":
    try:
        main()
    except Exception as e:
        error_output("CriticalFailure", "Script crashed properly", str(e))

Archeb avatar Feb 12 '26 11:02 Archeb

Guys, the new integration satellite is now released: https://github.com/techartdev/OpenClawHomeAssistantIntegration

techartdev avatar Feb 21 '26 17:02 techartdev

Hello, if I see this correctly, the app mounts the host systems /share and /media directories in rw mode. I am just starting to play with OpenClaw and would like it to not at some point decide to delete all my pictures, documents, etc. Yes, I have backups, but I would still very much prefer to just exclude this possibility.

Would it be possible to somehow configure the app in a properly isolated way? So that it has no write access to any directory on the host system or other home assistant apps? If I need to to get access to something, I could still make it mount things over network with its own credentials as mentioned above.

ast0815 avatar Apr 19 '26 10:04 ast0815