Skip to content

Using Pyscript In JupyterLab

Pyscript is a Home Assistant add-on (custom component) which allows you to ...

Setup

Install HACS

TBD

Install Pyscript

Install Pyscript from the HACS Integrations page:

Pasted image 20230330162813.png

Install JupyterLab

The addon can be installed from the Home Assistant add-on store.

Once it's installed it'll look something like this:

Pasted image 20230330161511.png

Click on Configuration then 'Edit in YAML':

Pasted image 20230330161650.png

Next, paste the code:

Pasted image 20230330161831.png

config.yaml
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
  # change this to your HA host's IP, see below
  - echo "hass_host = 1.2.3.4" >> /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
  - ln -sf /config/pyscript /config/notebooks/pyscript
  - curl https://raw.githubusercontent.com/craigbarratt/hass-pyscript-jupyter/master/pyscript_tutorial.ipynb -o /config/notebooks/pyscript_tutorial.ipynb

And click Save:

Pasted image 20230330161939.png

Click Restart:

Pasted image 20230330162027.png

You should now see "JupyterLab" in your Sidebar:

Pasted image 20230330162313.png

The file pyscript_tutorial.ipynb contains the PyScript tutorial:

Pasted image 20230330162509.png


Last update: 2023-03-30