18 lines
588 B
Bash
Executable file
18 lines
588 B
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Needs a .env.homeassistant with an API token in ~/.config/sway/.env.homeassistant
|
|
# TODO:
|
|
# - HA optimize API calls: https://community.home-assistant.io/t/get-limited-number-of-states-entities-when-using-api-states/830323
|
|
|
|
homeassistant_url="http://10.7.1.11:8123/api/states"
|
|
. ~/.config/sway/.env.homeassistant
|
|
|
|
. ~/bin/i3blocks/_utils
|
|
|
|
ha() {
|
|
local power=$(curl -s -H "Authorization: Bearer $ha_token" -H "Content-Type: application/json" $homeassistant_url/sensor.inspelning_oli_power | jq -r '.state')
|
|
local stat="PWR ${power}W"
|
|
echo "$stat"
|
|
}
|
|
|
|
ha
|