No description
Find a file
2025-09-30 09:41:03 -07:00
.github Mon Sep 29 05:30:26 PM PDT 2025 2025-09-29 17:30:26 -07:00
LICENSE Initial commit 2025-09-29 16:36:55 -07:00
README.md Update README.md 2025-09-30 09:41:03 -07:00
waybarha.py Tue Sep 30 09:38:21 AM PDT 2025 2025-09-30 09:38:21 -07:00

A module for Waybar that can show and toggle sensors from Home Assistant

screenshot

Dependencies

  • Python
  • Home Assistant with enabled Rest API (link1 and link2 to the docs)

Download

Download waybarha.py anywhere you have permission to read it

Usage

Edit the file to set your server's URL and the access token.

In your waybar's .jsonc, add one entry per entity you want to read/toggle. Examples:

 "custom/ha1": {
    "format": "󰌵 {text}",
    "exec": "/path/to/waybarha.py switch.lamp",
    "on-click": "/path/to/waybarha.py --toggle switch.lamp",
    "return-type": "json", /* this script outputs json; if you omit this the label will be a json output*/
    "interval": 5
  },
  "custom/ha2": {
    "format": "󰌵 {text}",
    "exec": "/path/to/waybarha.py switch.floor_lamp",
    "on-click": "/path/to/waybarha.py --toggle switch.floor_lamp",
    "return-type": "json",
    "interval": 5
  },
  "custom/ha3": {
    "format": "  {text}",
    "exec": "/path/to/waybarha.py sensor.2022_santa_cruz_fuel_level",
    "return-type": "json",
    "interval": 600 // 10 minutes
  }

Hint: if "format": "󰌵 {text}" has a square instead of a proper character (it's a light bulb) you need to install and use a nerd font.

This plugin exposes the entity's state as 'text', unless the entity's name starts with "switch" in which case the on/off states are exposed via css classes for styling.

Example of style.css:

#custom-ha1 {
	background: @background-primary;
	color: @sapphire;
	border-left: 4px solid @sapphire;
	margin: 6px 0;
	padding: 8px 12px;
}
#custom-ha1.on {
	background: @sapphire;
	color: @background-primary;
}
#custom-ha1.off {
	opacity: 0.7;
}
#custom-ha2 {
	background: @background-primary;
	color: @teal;
	border-left: 4px solid @teal;
	margin: 6px 0;
	padding: 8px 12px;
}
#custom-ha2.on {
	background: @teal;
	color: @background-primary;
}
#custom-ha2.off {
	opacity: 0.7;
}
#custom-ha3 {
	background: @background-primary;
	color: @lavender;
	border-left: 4px solid @lavender;
	margin: 6px 0;
	padding: 8px 12px;
	border-radius: 12px 0 0 12px;
}

The script takes 2 arguments:

  • optional - - toggle means this is a switch to toggle and can be omitted
  • the entity's id
./waybarha.py --help
usage: waybarha.py [-h] [-t] entity

Waybar home assistant module to query/toggle an entity

positional arguments:
  entity        entity to read or toggle - ex: 'switch.lamp'

options:
  -h, --help    show this help message and exit
  -t, --toggle  toggle entity on/off; entity's state will be read if omitted