question

Matt Knight avatar image
Matt Knight asked

Battery / Solar Metrics in Apple Touch Bar

Thought I'd try something fun this morning, so I came up with this little project.

The new MacBook Pro has an integrated Touch Bar along the top of the keyboard which is a touch sensitive OLED display. Using an app called BetterTouchTool (no affiliation, but just found it this morning: https://folivora.ai/) you can customize this to display the output of an arbitrary shell script.

So I threw together a quick app using NodeJS to poll the metrics from the MQTT broker on the CCGX and display them on the bar. If there's interest, I can clean up the code a little and put it on GitHub.

CCGX Color ControlMQTT
img-2293.jpg (2.8 MiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

4 Answers
mvader (Victron Energy) avatar image
mvader (Victron Energy) answered ยท

Hi @Matt Knight, super cool! I donโ€™t have a macbook; but if Iโ€™d ever get one.. :-)

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

ben avatar image
ben answered ยท

Thatโ€™s funny. Just last night, I decided to put some water tank and SOC metrics in the Menu Bar instead. I guess I am โ€œold schoolโ€? :D



I think just need some fancy Unicode glyphs now...


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Guy Stewart (Victron Community Manager) avatar image
Guy Stewart (Victron Community Manager) answered ยท

That looks great. If it is easy for you, I would love if you could post the code.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Tim from Eat Sleep Van avatar image
Tim from Eat Sleep Van answered ยท

Thanks to MQTT, Homebridge on a raspberry pi, and the mqttthing homebridge plugin, I have integration with Siri and homekit. I can now turn the inverter on/off via Siri/homekit and see the current battery level and voltage.

Here's my homebridge config for anyone interested. It works really well! The only snag is Homekit doesn't really support 'battery level' and 'voltage' as things, so you have to use humidity or temperature.

Cool features:

- You can use it from any homekit device on your network e.g. iPhone/laptop/ipad

- If you have a iPad, apple TV or homepod as a homekit base, you can control and see values remotely!

- Add basic home automation e.g. check at 1pm if the battery is full, turn on the hot water heater.

{
    "bridge": {
        "name": "PiHomebridge3",
        "username": "AA:BB:CC:DD:EE:FF",
        "port": 51826,
        "pin": "031-45-156"
    },
    "accessories": [
        {
            "accessory": "mqttthing",
            "type": "humiditySensor",
            "name": "Battery",
            "url": "http://ccgx.local:1883",
            "mqttOptions": {
                "keepalive": 30
            },
            "topics": {
                "getCurrentRelativeHumidity": {
                    "topic": "N/a0f6fd6b4064/battery/258/Soc",
                    "apply": "return (message!='') ? JSON.parse(message).value.toFixed(0) : 0;"
                }
            },
            "logMqtt": false
        },
        {
            "accessory": "mqttthing",
            "type": "temperatureSensor",
            "name": "Voltage",
            "url": "http://ccgx.local:1883",
            "mqttOptions": {
                "keepalive": 30
            },
            "topics": {
                "getCurrentTemperature": {
                    "topic": "N/a0f6fd6b4064/battery/258/Dc/0/Voltage",
                    "apply": "return (message!='') ? JSON.parse(message).value.toFixed(1) : 0;"
                }
            },
            "logMqtt": false
        },
        {
            "accessory": "mqttthing",
            "type": "switch",
            "name": "Inverter",
            "url": "http://ccgx.local:1883",
            "mqttOptions": {
                "keepalive": 30
            },
            "topics": {
                "setOn": "W/a0f6fd6b4064/vebus/257/Mode",
                "getOn": "N/a0f6fd6b4064/vebus/257/Mode"
            },
            "onValue": "{\"value\": 3}",
            "offValue": "{\"value\": 4}",
            "logMqtt": false
        }
    ],

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi Tim,

This is excellent and really deserving of its own post with some more details of how you did it.

Would you mind creating a new one in the Mod space?

0 Likes 0 ยท