Bash script to view live electricity consumption in MacOS terminal

Hi

I started playing around with the API curl examples and ended up recreating the live electricity consumption indicator, from the bright app, on the command line. I then tried make it reusable for others by pulling out the various resourceIds and prompting for username and password at first run. I've made it freely available in GitHub here:

https://github.com/glowenergydev/glow-bash

Authored on MacOS, I haven't tested this on Linux yet, it should work but if it doesn't it might be down to the sed command options. I'm using reg-ex in sed to parse the JSON output and get the info I want out of the response.

When it runs, it looks like this and the number updates every 10 seconds:

./glowbash.sh

electricity:898 Watts

Comments

  • That is great stuartr, always nice to have different ways to get the data and display it, I will have a play. Thank you for making this available.

  • Thanks stuartr, FWIW just given it a go on a Windows 10 machine and it runs fine under Windows Subsystem for Linux.

  • Can confirm this works fine on Linux (Mint 19.3), great work. :)

  • edited February 2021

    Would you expect this to work on a Raspberry Pi?

    After successful authorisation I get:-

    electricity:{"status":"OK","name":"electricity consumption","resourceTypeId":"e3a5db34-6e0c-4221-9653-8d33e27511ba","resourceId":"793b5726-a535-459f-9ad5-f144f6electricity:{"status":"OK","name":"electricity consumption","resourceTypeId":"e3a5db34-6e0c-4221-9653-8d33e27511ba","resourceId":"793b5726-a535-459f-9ad5-f144f6^Cd165","data":[],"classifier":"electricity.consumption","units":"kWh"} Watts

Sign In or Register to comment.