I have been playing around with matplotlib as a substitute for Gnuplot and wrote a quick script to create a chart that shows the health of all of my battery-powered devices. The script automatically picks up all the devices--when a new device is added to the system, it will automatically be added to the chart (implementations with a significantly different number of devices will require playing with the chart scaling parameters.)
When a battery drops below 10 percent, its bar will automatically turn yellow and below 5 percent it will turn red (many parameters can be easily adjusted in the script) The resulting image is placed in the appropriate Indigo directory to make it available in the control page editor. The script completes quickly, but I'd suggest running it as a linked script (rather than embedded), and I believe all components are available natively in OS X. Note: to make it look its best on a control page, you need to browse to the image to note it's dimensions.
I'm pretty happy with the results so far. Enjoy!
Dave
EDIT: Updated to include:
- Device names sorted alphabetically
- Error trapping for imports, device information gathering, data parsing
- Karl's data point labels (look for setting: show_data_labels [True/False])
EDIT 2: Updated to include:
- moved the data labels inside the ends of the bars,
- moved all bars up to keep them from crowding the x axis,
- moved the y axis labels slightly to actually be centered (for 2 line labels),
- picks up devices with battery level of zero,
- adds a 'fontname' value to specify a choice.
EDIT 3:
- coerces a battery level of zero when device reports an empty string for its battery level.
EDIT 4:
- fixes error where coercions were improperly created as strings.
Confirmed to work under:
Python 2.6.8
Matplotlib 1.1.1
Indigo Server 6.1.7
To download the Python 2 version, visit the link below and select the Python 2 fork.
EDIT 5:
- Updates script to Python 3 to work with Indigo 2022.1.
Confirmed to work under:
Python 3.10.2
Matplotlib 3.5.1
Indigo Server 2022.1
To download the Python 3 version, visit the link below and select the Master fork.
You can download the script on GitHub.
[EDIT] Move script to GitHub.