Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HASS="http://1.2.3.4"
TOKEN="middlefinger"
PARAMETERS="-s -X GET -H 'Content-Type: application/json'"
CURL="/usr/bin/curl"
#CURL="curl -s -X GET -H 'Content-Type: application/json' -H \"Authorization: Bearer ${TOKEN}\" ${HASS}/api/states"
${CURL} ${PARAMETERS} -H "Authorization: Bearer ${TOKEN}" --connect-timeout 1 ${HASS}/api/ | grep -q "running"
if [ $? -eq 0 ]
then
TI=$(${CURL} ${PARAMETERS} -H "Authorization: Bearer ${TOKEN}" ${HASS}/api/states/sensor.temperature | jq -r '.state')
TO=$(${CURL} ${PARAMETERS} -H "Authorization: Bearer ${TOKEN}" ${HASS}/api/states/sensor.temperature_outside | jq -r '.state')
HO=$(${CURL} ${PARAMETERS} -H "Authorization: Bearer ${TOKEN}" ${HASS}/api/states/sensor.humidity_outside | jq -r '.state')
echo "${TI}º |"
echo "---"
echo "${TO}º outside"
echo "${HO}% humidity outside"
else
echo "X |"
echo "---"
echo "Unreachable"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.