Display OpenHAB Items in MacOS menu bar

Hi there,

how can I display the states and values of a few OpenHAB items in the Mac menu bar (like temperature and light/switch states).

I found this thread Control OpenHAB via Gnome Shell Linux / MacOS Menu Bar (Argos, BitBar) but I’m not very good with shell scripting. Maybe someone could point me in the right direction.

Looking forward to hear from you.

Hi, for my understanding it is not for MacOS, it`s only inspired by it!

Hi Jesco,

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.

Ah, OK. Indeed it would be a very nice feature!

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.

UPDATE:

curl -X GET --header "Accept: text/plain" "http://openhabianpi:8080/rest/items/<itemname>/state"

Thing is:
I don’t know how to use that GET API call in a shell script. In the other thread there are only “POST” commands.

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