• Stars
    star
    851
  • Rank 53,558 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pyscript adds rich Python scripting to HASS

Pyscript: Python Scripting for Home Assistant

GitHub Release License hacs Project Maintenance

This HACS custom integration allows you to write Python functions and scripts that can implement a wide range of automation, logic and triggers. State variables are bound to Python variables and services are callable as Python functions, so it's easy and concise to implement logic.

Functions you write can be configured to be called as a service or run upon time, state-change or event triggers. Functions can also call any service, fire events and set state variables. Functions can sleep or wait for additional changes in state variables or events, without slowing or affecting other operations. You can think of these functions as small programs that run in parallel, independently of each other, and they could be active for extended periods of time.

Pyscript also provides a kernel that interfaces with the Jupyter front-ends (eg, notebook, console, lab and VSCode). That allows you to develop and test pyscript code interactively. Plus you can interact with much of HASS by looking at state variables, calling services etc.

Documentation

Here is the pyscript documentation.

For more information about the Jupyter kernel, see the README. There is also a Jupyter notebook tutorial, which can be downloaded and run interactively in Jupyter notebook connected to your live HASS with pyscript.

Installation

Option 1: HACS

Under HACS -> Integrations, select "+", search for pyscript and install it.

Option 2: Manual

From the latest release download the zip file hass-custom-pyscript.zip

cd YOUR_HASS_CONFIG_DIRECTORY    # same place as configuration.yaml
mkdir -p custom_components/pyscript
cd custom_components/pyscript
unzip hass-custom-pyscript.zip

Alternatively, you can install the current GitHub master version by cloning and copying:

mkdir SOME_LOCAL_WORKSPACE
cd SOME_LOCAL_WORKSPACE
git clone https://github.com/custom-components/pyscript.git
mkdir -p YOUR_HASS_CONFIG_DIRECTORY/custom_components
cp -pr pyscript/custom_components/pyscript YOUR_HASS_CONFIG_DIRECTORY/custom_components

Install Jupyter Kernel

Installing the Pyscript Jupyter kernel is optional. The steps to install and use it are in this README.

Configuration

  • Go to the Integrations menu in the Home Assistant Configuration UI and add Pyscript Python scripting from there. Alternatively, add pyscript: to <config>/configuration.yaml; pyscript has two optional configuration parameters that allow any python package to be imported if set and to expose hass as a variable; both default to false:
    pyscript:
      allow_all_imports: true
      hass_is_global: true
  • Add files with a suffix of .py in the folder <config>/pyscript.
  • Restart HASS.
  • Whenever you change a script file, make a reload service call to pyscript.
  • Watch the HASS log for pyscript errors and logger output from your scripts.

Contributing

Contributions are welcome! You are encouraged to submit PRs, bug reports, feature requests or add to the Wiki with examples and tutorials. It would be fun to hear about unique and clever applications you develop. Please see this README for setting up a development environment and running tests.

Even if you aren't a developer, please participate in our discussions community. Helping other users is another great way to contribute to pyscript!

Useful Links

Copyright

Copyright (c) 2020-2023 Craig Barratt. May be freely used and copied according to the terms of the Apache 2.0 License.

More Repositories

1

ble_monitor

BLE monitor for passive BLE sensors
Python
1,895
star
2

remote_homeassistant

Links multiple home-assistant instances together
Python
884
star
3

nordpool

This component allows you to pull in the energy prices into Home-Assistant.
Python
443
star
4

custom_updater

[DEPRECATED]πŸ“¦ A component which allows you to track and update custom cards/components and python_scripts
Python
166
star
5

grocy

Custom Grocy integration for Home Assistant
Python
156
star
6

feedparser

πŸ“° RSS Feed Integration
Python
137
star
7

sensor.unifigateway

High level health status of UniFi Security Gateway devices via UniFi Controller
Python
127
star
8

weatheralerts

A sensor that gives you weather alerts from alerts.weather.gov.
Python
126
star
9

climate.programmable_thermostat

Programmable thermostat that let you have a smart thermostat on budget.
Python
113
star
10

places

Component to integrate with OpenStreetMap Reverse Geocode (places)
Python
111
star
11

media_player.braviatv_psk

Sony Bravia TV (Pre-Shared Key) component for Home Assistant
Python
106
star
12

sensor.rpi_power

A Custom component for Home-Assistant that checks if your Raspberry Pi power supply is giving enough voltage from the kernel.
Python
103
star
13

sensor.airthings_wave

hassio support for Airthings Wave BLE environmental radon sensor.
Python
100
star
14

sensor.plex_recently_added

▢️ Plex component to feed Upcoming Media Card.
Python
82
star
15

authenticated

A platform which allows you to get information about sucessfull logins to Home Assistant.
Python
82
star
16

breaking_changes

Component to show potential breaking_changes in the current published version based on your loaded components
Python
81
star
17

zaptec

zaptec charger custom component for home assistant
Python
63
star
18

sensor.trakt

πŸ“Ί Trakt Integration for Upcoming Media Card
Python
61
star
19

sensor.radarr_upcoming_media

🎬 Radarr component to feed Upcoming Media Card.
Python
59
star
20

youtube

A platform which give you info about the newest video on a channel
Python
55
star
21

sensor.sonarr_upcoming_media

πŸ“Ί Sonarr component to feed Upcoming Media Card.
Python
54
star
22

healthchecksio

Update and display the status of your healthchecks.io checks.
Python
51
star
23

sensor.avanza_stock

Custom component to get stock data from Avanza for Home Assistant
Python
46
star
24

sensor.ssh

SSH Generic Sensor
Python
43
star
25

sensor.untappd

🍻 Untappd Integration
Python
37
star
26

readme

Use Jinja and data from Home Assistant to generate your README.md file
Python
33
star
27

information

πŸ“œ Information about this organization
31
star
28

sensor.stadtreinigung_hamburg

Stadtreinigung Hamburg - get garbage collection dates in Hamburg - custom component for Home Assistant
Python
25
star
29

sensor.yandex_maps

A platform which give you the time it will take to drive.
Python
25
star
30

combined

A camera platform that give you a combined feed of your defined camera entities.
Python
24
star
31

wienerlinien

A sensor that give you information about next departure from spesified stop.
Python
21
star
32

templatesensor

Add template sensors from the UI.
Python
19
star
33

uilogs

DEPRECATED: Custom panel that show colorful logs for Home Assistant (core), and the supervisor (if you have it).
TypeScript
18
star
34

sensor.nintendo_wishlist

A sensor that monitors a Nintendo Switch wish list for when games are on sale.
Python
17
star
35

sensor.personalcapital

πŸ’΅ Personal Capital Integration for Bank Account Monitoring
Python
15
star
36

switch.hadockermon

A switch platform that interact with ha-dockermon.
Python
14
star
37

unsplash

A camera platform that give you random images from Unsplash presented as a camera feed.
Python
13
star
38

gpodder

🎧 gPodder Integration for Podcast Feed Monitoring
Python
13
star
39

sensor.owlintuition

A set of sensors to integrate the OWL Intuition devices network
Python
11
star
40

sensor.file_restore

Improved file sensor component that let you read the whole last line content.
Python
11
star
41

usps_mail

A component that give you to info about incoming letters and packages from USPS.
Python
9
star
42

sensor.custom_aftership

A component which allows you to get information about pending parcels.
Python
8
star
43

sensor.tautulli

A platform which allows you to get information from Tautulli.
Python
8
star
44

sensor.avfallsor

Simple sensor for avfallsor
Python
8
star
45

brewdog

🍻 Display information about random beers from Brewdog as a sensor in Home Assistant, you can use this in a push notification next time you visit a bar.
Python
7
star
46

sensor.kodi_recently_added

Kodi component to feed the Upcoming Media Card for Home Assistant.
Python
7
star
47

config_check

Run the CLI config_check from a service call.
Python
7
star
48

ups

The ups platform allows one to track deliveries by the UPS
Python
6
star
49

fedex

The fedex platform allows one to track deliveries by FedEx
Python
5
star
50

sensor.launchlibrary

Get info about next space launches
Python
4
star
51

climate.e_thermostaat

E-Thermostaat (ICY) component for Home Assistant
Python
3
star
52

custom_components

[archived] Use this instead: https://github.com/custom-components/custom_updater
Python
3
star
53

camera.multisource

A camera platform that generate a camera feed from multiple sources.
Python
2
star
54

srp_energy

The srp_energy integration shows information from Srp hourly energy usage report for their customers
Python
2
star
55

hassbian_config

A custom component which allows you to controll some hassbian-config functions from Home Assistant.
Python
2
star
56

sensor.ruter

A sensor platform that gives you information about next departures.
Python
2
star
57

lists

Python
2
star
58

sensor.wifi-scanner

A Wi-Fi scanner sensor
Python
2
star
59

sensor.versions

Deprecated.
Python
2
star
60

sensor.custom_cards

This sensor is no longer needed
Python
1
star
61

sytadin

The sytadin sensor platform allows you to monitor traffic details from Sytadin
Python
1
star
62

sickchill

Taps into Sickchill Api so you can perform basic commands
Python
1
star
63

complimentr

Component to integrate with complimentr.
Python
1
star
64

binary_sensor.hadockermon

A custom binary_sensor platform which allows you get sensor data from ha-dockermon.
Python
1
star