Skip to content


DaveL17 edited this page May 15, 2019 · 17 revisions

Color Palettes
Creating Custom CSV Data
Using Adjustment Factors
Using Custom Axis Labels

Color Palettes

One key to making good looking charts is to select an appealing color palette.

There is a ton of information online about color selection and this is one area where you'll often find that a palette that looks good to one person will offend another. You should definitely use whatever looks good to you. When you look under the hood, the plugin uses the standard RGB color value -- which is a six digit hex code to reflect the proportion of Red, Green and Blue (R-G-B). When selecting colors with the OS X color picker, you should find that any color selected using that tool should work. However, it's recommended that you find one method within the tool to set your colors and stick with that. Some people prefer to use the Crayon view. I prefer the 'RGB Sliders' control and I enter the RGB code into the 'Hex Color #' field.

The RGB hex color code has two digits per color: #RRGGBB (the color picker tool takes care of the hashtag bit.) The values for each color are bounded by the numbers 0-9 and A-F. The values range from 0-F with 0 (zero) being no color and F being full color. In other words, a red value (the first two digits of RRGGBB) of 00 would mean no red. A red value of FF would mean full red. All zeroes (#000000) means no color (black) and all F's (#FFFFFF) means full color (white). Again, there's lot's of information online that explains all this, but I wanted to make sure to explain this small part here because it factors directly into the colors I use and how I pick them.

Color Value
Black #000000
Shades of gray: #111111 - #999999
Red: #FF0000
Green: #00FF00
Blue: #0000FF
White: #FFFFFF

Note the F's in the values above. These colors are nice and contrasty, but you may find that you need more options than this. Then it's a matter of taste, but I like to use the inherent math for balance. Using the range: 0-1-2-3-4-5-6-7-8-9-A-B-C-D-E-F, there are 16 potential values for each digit. So one of my additional colors is yellow (a combination of red and green) so the yellow color I use is #FFFF00. You get the idea. After that, I try to find something discrete steps between two colors. For example, to get orange, I use #FF7F00 (full red, "half" green, no blue)--the value 7 is the middle of the green scale 00 through FF. How many combinations are there? A lot. (If memory serves, it's 6 digits with 16 choices or 16^6 = 16,777,216.

Play with the color values in the color picker. While this may seem complex at first, it's really quite simple once you get the hang of it. There is a never ending, very "enthusiastic" debate about color selection out there. If you stick to colors that you like, none of that matters.

Creating Custom CSV Data

The CSV Engine device works well for taking snapshots of data at routine intervals (I have mine set to log every 15 minutes). However, sometimes you may wish to have more granular logging to track the exact times that certain events take place or to log every change to a device. This is a fairly easy thing to do when you combine the power of Indigo Triggers and a little bit of simple Python programming. You do not need to know how to program Python to use this method. Note that there are other ways to track all changes to a device--including using Indigo's built-in SQL Logger plugin--the benefit of the following method is that you have a greater level of control over the conditions governing when the logging takes place.

Example - Logging a Dehumidifier

I have my basement dehumidifier plugged into an Aeotec Smart Switch 6. The Smart Switch reads power usage, so I can use that to determine whether the dehumidifier is running or idle based on the power being consumed. When running, the dehumidifier uses approximately 80 Watts, so I decided to consider any draw greater than 75 Watts to be 'on' and any draw less than 75 Watts to be 'off'. To log the change in the dehumidifier's state, I created two Indigo Triggers: one for 'running' and one for 'not running'.

  • Trigger:
    • Name: "Dehumidifier - Off State"
    • Type: Device State Changed
    • Device: Basement - Dehumidifier
    • Current Load (Watts)
    • Becomes Less Than 75.
  • Condition
    • (I used no conditions)
  • Actions:
    • Execute Script (Script and File Actions)
    • Embedded Python

View Full Size

View Full Size

Paste the following code into the scripting window:

import os
import datetime

data_file = "/Users/dave/Dropbox/Indigo Logs/dehumidifier.csv"
heading = "dehumidifier"

if not os.path.isfile(data_file):
    with open(data_file, 'a') as outfile:
        outfile.write(u"{0},{1}\n".format("timestamp", heading))

with open(data_file, 'a') as outfile:
    outfile.write(u"{0},{1}\n".format(, 'False'))

A few notes about the Python script. The first group of lines set the environment variables for the script--where to write the data, and a column heading for the data file. The second group of lines will check to determine if a valid file exists for the data to be stored and will create the file if it doesn't exist. The third group of lines will write the actual data to be logged.

You will need to change a couple lines to fit your installation:

  1. data_file (change this to point to your folder and filename). To use the resulting data in the matplotlib plugin, you should save the file to the same folder where your other CSV data reside.
  2. heading (change this to something appropriate for your needs.)

When the power draw becomes less than 75 Watts, the script writes a timestamp and 'false' to indicate the dehumidifier is not running.

Once you've saved the Trigger, duplicate it and change the trigger's name to 'Dehumidifier - On State', change 'Becomes Less Than' to 'Becomes Greater Than', and change the Python script to write 'true' instead of 'false'. Be sure to save your changes.

Important Note: this script will continue to write to this file without any consideration to the total number of observations within the file. So, over time, the number of observations could become quite large.

Using Adjustment Factors

You can elect to use a chart adjustment factor to allow multiple sources to be displayed on the same chart with finer-grained control over how the data are displayed. For example, the following chart displays four binary data elements. Each has values of 0 or 1 so the chart wouldn't be useful because all four lines would be plotted on top of each other. By applying an adjustment factor to one or more of the lines, we can shift where they appear on the chart. Note that for visual appeal, we have raised the first device off the X axis by adding to its value (+1). In this instance, the effect was achieved by applying a simple linear transformation to the data to be charted:

Item Setting
Line 1 + 1 (plots on 1 and 2)
Line 2 + 3 (plots on 3 and 4)
Line 3 + 5 (plots on 5 and 6)
Line 4 + 7 (plots on 7 and 8)
Tick Labels off,on,off,on,off,on,off,on
Tick Locations 1,2,3,4,5,6,7,8
Y Axis Range 0-9

Line Chart with Adjustment
View Full Size

These transformations are applied in real time and do not change the underlying data

Using Custom Axis Labels

Matplotlib helpfully tries to set axis ticks and labels for us. However, sometimes, its best guess isn't good enough and you might find your axis labelled with values like (0, 0, 1, 1, 2, 2). You can often adjust the precision setting of the scale to a finer level and fix that condition. However, you can also elect to use custom labels on the Y axis of select chart types. This gives you greater control over how your axis will appear.

For example, consider the following wind direction chart:

Wind Direction Chart
View Full Size

Note the labels on the Y axis connoting direction. In this case, the data being plotted are compass directions in degrees (0-360).

To change the Y axis labels, go into the device settings and tick the Y axis controls group if it's not already displayed.

Custom Tick Labels
View Full Size

In this instance, we want five marks on the Y axis to represent compass degree direction values of 0, 90, 180, 270, and 360. Add corresponding custom labels int the 'Tick Labels' field. Note that the number of tick labels and the number of tick locations must be equal in order for them to display properly. It's also best for the tick location data to be within the expected range of the data to be charted.

Label Location
N 360
W 270
S 180
E 90
N 0

You can also use this feature to force your charts to display Y axis values in a preferred way. For example, for a relative humidity chart, you might set the Y axis min/max to be 0 - 100 but you also might only want four Y axis labels:

Label Location
25 25
50 50
75 75
100 100

Or only three labels:

Label Location
25 25
50 50
75 75

or add units:

Label Location
25% 25
50% 50
75% 75
100% 100
You can’t perform that action at this time.