Skip to content

Doc Request: Add instructions for using the JupyterLab community add-on to run the PyScript kernel #32

@rct

Description

@rct

The instructions in this issue over in the PyScript repo cover installing the PyScript kernel in the Home Assistant Community Add-On for JupyterLab.

This might be the easiest way for most people (using Home Assistant OS) to get the kernel running. As mentioned by the author of that issue @chancancode, the advantages are:

  • Don't need to have a local install of Jupyter and Python on desktop/laptop.
  • The kernel can be installed/made to run by pasting some YAML into the add-on's config.
  • Home Assistant's supervisor/add-on infrastructure takes care of the access token, IP address, etc.

One advantage/caveat is that It runs on the Home Assistant server, so likely a minimum of a 4GB RAM is needed for Home Assistant plus add-ons.

I haven't done extensive testing but I haven't come across any issues that don't come up for other environments.

Here's the YAML I'm using in the add-on's configuration:

github_access_token: ""
system_packages: []
init_commands:
  - pip install hass_pyscript_kernel
  - jupyter pyscript install
  - >-
    echo "[homeassistant]" >
    /usr/local/share/jupyter/kernels/pyscript/pyscript.conf
  - >-
    echo "hass_host = homeassistant" >>
    /usr/local/share/jupyter/kernels/pyscript/pyscript.conf
  - >-
    echo "hass_url = http://supervisor/core/" >>
    /usr/local/share/jupyter/kernels/pyscript/pyscript.conf
  - >-
    echo "hass_token = $SUPERVISOR_TOKEN" >>
    /usr/local/share/jupyter/kernels/pyscript/pyscript.conf
  - mkdir -p /config/notebooks/pyscript
  - ln -sf /config/pyscript /config/notebooks/pyscript/config-pyscript
  - >-
    curl
    https://raw.githubusercontent.com/craigbarratt/hass-pyscript-jupyter/master/pyscript_tutorial.ipynb
    -o /config/notebooks/pyscript/pyscript_tutorial.ipynb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions