[APP][Pro] Python Script

Hi all,

I built a Homey app that lets you run Python code directly from Advanced Flows.

Three flow cards:

Run Script — Python inline in the card, sandboxed (no network, no filesystem). Good for
logic and calculations. Output: return_value and error flow tokens.

Run Script with Packages — full Python with pip packages. Install requests, numpy,
anything. Packages are cached in a virtual environment. Full Homey API access.

Run Named Script — save scripts in the built-in IDE, call them by name from any flow.
Sandbox mode and venv configured in the IDE, not the card.


From non-sandboxed scripts (Run Script with Packages, Run Named Script):

# Read a logic variable
value = await homey.logic.get_variable("temperature")

# Read or control a device capability
state = await homey.devices.get_capability(device_id, "onoff")
await homey.devices.set_capability(device_id, "dim", 0.5)

# Trigger a flow (add the "Flow triggered from Python" trigger card to that flow first)
await homey.flow.trigger("my-tag")

return "done"

Note: homey.logic.set_variable() is not supported — Homey restricts logic variable
writes to the HomeyScript app only.

Note: homey.logic, homey.devices, and homey.flow are NOT available in the sandboxed
“Run Script” card — they raise RuntimeError. Use return to pass values to the flow.


Example — fetch live weather (Run Script with Packages, venv with requests installed):

import requests
r = requests.get("https://api.open-meteo.com/v1/forecast?latitude=52.37&longitude=4.90&current=temperature_2m")
return r.json()["current"]["temperature_2m"]

The return value becomes the return_value flow token. If the script raises an exception,
the error flow token is set automatically.


IDE — settings page with Monaco editor (same as VS Code), Python syntax highlighting,
run directly from the IDE, manage virtual environments.

Install: Python Script | Homey
Source: GitHub - jaccoh/homey-pythonscript: A Homey app to execute Python script in cards · GitHub

Requires Homey Pro (local) or SHS v13.0.0+. Bugs and PRs welcome.


Changelog

v0.3.2

  • Fixed: new script name now appears in dropdown immediately after creating,
    without needing to save first

v0.3.1

  • App Store compliance: plain text readme, new icon, real screenshot

v0.3.0

  • error flow token now declared on all cards — use it in subsequent flow cards
  • Sandboxed card: homey.logic/devices/flow now raise a clear error instead of
    silently doing nothing (they were never supported in sandbox mode)
  • Fixed: script syntax errors in non-sandboxed cards now surface as an error
    instead of silently succeeding with an empty return value
  • Fixed: concurrent bridge calls no longer race on the IPC channel
  • Removed dead code (sandbox.py, unused HomeyContext internals)

v0.2.3

  • homey.flow.trigger(“tag”) working via trigger card mechanism
  • homey.logic.get_variable() — read logic variables from Python
  • homey.devices.get_capability() / set_capability() — read and control devices
  • Fixed: sandboxed card could not be killed on timeout (now uses subprocess)
  • Fixed: IPC pump robustness (KeyError, BrokenPipe, subprocess leak)

v0.2.2

  • Initial release

Did you even run your own app? Seems your Claude has completely hallucinated stuff.

Ofcourse I did, I’m running it as I speak to open and close curtains via Python. I’ll have a look if I can reproduce this.

by the way, I clearly stated its a very very early version… so… cut me some slack.. it really works

Please try 0.3.0 like so: