HAOS and Shell script - Bluetooth speaker status

Hello to everyone.

I have BT Speaker connected to HAOS. I also have shell script that I execute if speaker is disconnected ( ./bt_music_connect.sh)

#!/bin/bash
MAC="54:D9:32:02:50:65"
powered() {
    echo "show" | bluetoothctl | grep "Powered" | cut -d " " -f 2
}

connected() {
    echo "info ${MAC}" | bluetoothctl | grep "Connected" | cut -d " " -f 2
}

while true
do
    sleep 1
    if [ $(powered) = yes ] && [ $(connected) = no ]; then
        echo "connect ${MAC}" | bluetoothctl
        sleep 5
    fi

    if [ $(powered) = yes ] && [ $(connected) = yes ]; then
        echo "Succesfull connection to ${MAC}"
        exit
    fi

done

I would like to have entities or device with entities that will have values that i get from shell script (connected or not)

Further searching I found that with curl command I can send sensor values and that is clear. I am not clear with authentication even reading documentation.

Thank you.