19 lines
803 B
Bash
Executable file
19 lines
803 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 temp_indoor=$(curl -s -H "Authorization: Bearer $ha_token" -H "Content-Type: application/json" $homeassistant_url/sensor.vindstyrka_oli_temperature | jq -r '.state')
|
|
local humidity_indoor=$(curl -s -H "Authorization: Bearer $ha_token" -H "Content-Type: application/json" $homeassistant_url/sensor.vindstyrka_oli_humidity | jq -r '.state')
|
|
local stat="IN ${temp_indoor}°C ${humidity_indoor}%"
|
|
echo $stat
|
|
}
|
|
|
|
ha
|