right, it’s not for MacOS but I’m looking for a solution to display OpenHAB items in the Mac menu bar and I’m not very familiar with shell scripting an API calls to display items there.
Hi, I cannot try it on Mac, but on the Argos website, they say, it is 100% compatible to BitBar. So, you can simply try to use the very same script as in the other thread.
Sending commands (POST requests) is actually much easier than reading and displaying a state (GET). I will create you an example for Argos / BitBar within the next days.
I played around with TextBar and came to this solution to display simple switch states. First: declare an array and list all OpenHAB items you want to check.
RED DOT before ItemName if switch CLOSED, OFF or 0
GREEN DOT before ItemName if switch OPEN, ON or 1
#!/bin/bash
declare -a OpenHABitems=(
"ItemName1"
"ItemName2"
"ItemName3"
"ItemName4"
"ItemName5"
)
STATUS=""
for habitem in "${OpenHABitems[@]}"
do
response=$(curl -X GET --header "Accept: text/plain" "http://openhabianpi:8080/rest/items/$habitem/state")
if [ "$response" = "OPEN" ] || [ "$response" = "ON" ] || [ "$response" = "1" ]
then
printf "\e[92m●\e[39m$habitem "
fi
if [ "$response" = "CLOSED" ] || [ "$response" = "OFF" ] || [ "$response" = "0" ]
then
printf "\e[91m●\e[39m$habitem "
fi
done
cat $STATUS