Matplotlib Plugin for Indigo 7 - New!

Posted on
Sun Nov 13, 2016 9:24 am
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Matplotlib Plugin for Indigo 7 - New!

Introducing the Matplotlib Plugin for Indigo 7

Download it Here.

Highlights:
- Easily create visually appealing charts for Indigo control pages.
- Seamlessly manage attributes like color, fonts, sizes (and more!) for all charts at once.
- Customize individual charts with markers, annotations, minimums and maximums, and user-defined constants.
- Chart types Include: Line Charts, Bar Charts, Polar Charts, Multiline Text Charts, and WUnderground Plugin Charts.
- Chart data that is created with the plugin, or incorporate your own (CSV).
- Charts update automatically.

The Matplotlib plugin is designed to make creating visually appealing charts for Indigo control pages. Many of the chart attributes, such as background color, font styles and chart size can be managed centrally--for example, you can change the background color of all your charts simultaneously. You can add additional customizations to each individual chart if you like, such as overriding the default chart size or displaying a chart legend only on selected charts. The overriding emphasis in designing the plugin is simplicity. The instructions below seem like a lot, but almost all of the settings can be left as default when you begin. It's best to read through all these instructions before getting started.

Plugin Settings:
The plugin configuration dialog is the first place that you will land when you first install the plugin. Chances are that you will be able to leave most of these settings alone when you begin. The configuration menu looks like this:
Screen Shot 2016-11-13 at 8.24.57 AM.png
Screen Shot 2016-11-13 at 8.24.57 AM.png (135.33 KiB) Viewed 3220 times

Save Data Files To: This is where the plugin will look for data to chart. The plugin can plot your CSV data or if you choose, the plugin can create CSV data files for you (more on the data in a bit). The specified folder must be visible to the server at all times.

Save Images To: This is the folder where the plugin will saye the image files that it creates. If the default folder is used, the images will be automatically available in the control page editor.

Refresh Interval: How often the plugin will generate a new version of your charts.

Resolution: The resolution of the image files (in DPI). The default is 100 and will probably work just fine for most users.

Size for Rectangular Charts, Extra Wide Rectangular Charts, and Square Charts: The default sizes for each chart. These values are in pixels. Square charts only need one value which is used for length and width.

Chart Properties: These control the look and feel of all of your charts. A note about colors. You can use the standard palette of colors or--if you enable the feature in advanced settings--you can select "Custom". if you select "Custom", a new field will appear for you to enter your custom color. These values are HTML color values (see the image above for an example) or standard color names (like Blue or Green). There is also an additional color option for the chart background and the cart canvas which allows these values to be transparent.

Debugging:
The plugin takes advantage of Indigo 7's enhanced debug logging facility:
Screen Shot 2016-11-13 at 8.45.22 AM.png
Screen Shot 2016-11-13 at 8.45.22 AM.png (43.9 KiB) Viewed 3220 times

The default for logging is "Warning" which will alert you only to issues that you may want to address. Select "Informational Messages" to see select notifications of plugin activity. The logging levels are inclusive of "higher" levels. In other words, if you set the level to Informational Messages, you'll also receive all Warnings, Errors and Critical messages.

CSV Data
Once you save your settings, the next thing that you might want to do is generate some CSV data. This is done using the plugin's built-in CSV Data Engine. To establish your CSV Engine, create a new Indigo Device, select Matplotlib as the device type and CSV Engine as the device model.
Screen Shot 2016-11-13 at 8.52.13 AM.png
Screen Shot 2016-11-13 at 8.52.13 AM.png (115.08 KiB) Viewed 3220 times

For each element, you must add three things: a title, a device number (or variable number) and a device state (or variable value). Once entered, then select "Add Item". Note that things you add here are not fully committed until you hit the save button. Use the second configuration area to modify or delete existing data elements. Again, changes will not be fully committed until you select save. Only data generated by the plugin can be managed with the CSV engine--if you add CSV data external to the plugin, you're on your own. If you choose to use the feature, you only need to create one CSV engine device. If you add additional CSV data elements, add them using the same CSV Engine device. After you add a new element, it will take some time for the CSV data to be generated. The first observation will be added the next time the plugin cycles (which is set in the plugin configuration dialog above). Each time the plugin cycles, it will generate new CSV data and then will create new charts (to ensure the most recent observations are included).

TIP: An easy way to identify the states associated with any device is to run the following code from an Indigo Script window. Replace 'DEVICE_ID' with the ID number for your specific device. Avoid using states that end in 'ui.' Variables only have one--called 'value'.
Code: Select all
indigo.server.log(unicode(indigo.devices[DEVICE_ID].states))


If you are successful, the plugin will generate CSV files like this:
Screen Shot 2016-11-13 at 8.31.58 AM.png
Screen Shot 2016-11-13 at 8.31.58 AM.png (75.17 KiB) Viewed 3220 times


Your First Plot
Once you have some data to chart, it's time to create your first plot. Plots are built using Matplotlib Plugin Devices. Create a new device and enter the configuration dialog. Most of these settings should be self explanatory, but one or two deserve additional explanation.
Screen Shot 2016-11-13 at 9.07.00 AM.png
Screen Shot 2016-11-13 at 9.07.00 AM.png (97.58 KiB) Viewed 3220 times

Output Filename: Here, we just enter the full name of the chart--something like: chart_illumination.png. You shouldn't include a path, that is set in the main plugin configuration dialog.

Some fields require a valid value or the word 'None'--if you set the value to None, the setting will be ignored. For example, a custom width value must either be a valid value in pixels or None. A blank will cause an error. If there's a problem, the plugin will try to fix the error for you. Other things can be blank -- like a title -- because entering 'None' will generate a title 'None'!

Custom Line Segments: this information (if enabled) requires a pair of values: a value to chart and a color presented as tuples: (123.4, 'blue'), (234.5, 'green').

Advanced Settings:
There are some advanced settings which enable additional features and affect how the plugin functions:
Screen Shot 2016-11-13 at 9.09.40 AM.png
Screen Shot 2016-11-13 at 9.09.40 AM.png (125.7 KiB) Viewed 3220 times

Enable Custom Colors: the plugin is limited to standard color options until this setting is enabled.
Enable Custom Line Segments: custom line segments are not available until this setting is enabled.
Promote Custom Line Segments: if selected, the chart's Y axis will be expanded to ensure that the custom value is always visible.
Enable Snappy Menus: if selected, this will cause all expandable menus to be minimized when first opened.

Last, and certainly not least -- some charts!
chart_illumination.png
chart_illumination.png (17.25 KiB) Viewed 3220 times

chart_10_day_forecast.png
chart_10_day_forecast.png (35.6 KiB) Viewed 3220 times

chart_wind_rose.png
chart_wind_rose.png (18.05 KiB) Viewed 3220 times


Your charts will be located in the folder that you established in your plugin preferences setting. You can view them in finder, but it's much better to add them to Indigo control pages. If you opted to keep the default image saving location, you can add them to a control page easily by adding a new Static Image--your charts should be listed in the dropdown list of images. If you selected another location, you can add the image as a Refreshing Image by adding 'file:///" and then listing the full path to the image (that's three slashes at the start). It will look something like this:
file:///Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/images/controls/static/filename.png

Some Tips:
- Leave the settings at default whenever possible as you begin.
- It's helpful to have some data to chart.
- When naming your charts, it's helpful to give them similar names. I start everything with 'chart_' so that they will all appear together in the control page list.
- Make a small number of changes at a time to see how the changes affect your charts. A bunch of changes at once can make it difficult to figure out what went wrong (if you don't like the result).

Overall, start simple and get used to the function of the plugin. Although this seems like a lot of explanation, once you get the hang of it, the simplicity of the plugin will become apparent. Most of all, enjoy!

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Nov 13, 2016 10:35 am
durosity offline
User avatar
Posts: 3544
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Matplotlib Plugin for Indigo 7 - New!

So uh.. where can i download this from then? ;)

Computer says no.

Posted on
Sun Nov 13, 2016 12:42 pm
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Re: Matplotlib Plugin for Indigo 7 - New!

durosity wrote:
So uh.. where can i download this from then? ;)

You found Indigo 7 before Matt & Jay hit enter, but you can't find the plugin? :mrgreen:

It's in the Indigo File Library.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Nov 13, 2016 12:43 pm
durosity offline
User avatar
Posts: 3544
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Matplotlib Plugin for Indigo 7 - New!

Well you didn't link to it did you? ;)

Computer says no.

Posted on
Sun Nov 13, 2016 1:05 pm
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Re: Matplotlib Plugin for Indigo 7 - New!

I can't see why you weren't able to find the big purple link in the top post that was added sometime after you looked.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Nov 13, 2016 2:16 pm
durosity offline
User avatar
Posts: 3544
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Matplotlib Plugin for Indigo 7 - New!

Image


Sent from my iPad using Tapatalk

Computer says no.

Posted on
Sun Nov 13, 2016 5:00 pm
norcoscia offline
User avatar
Posts: 508
Joined: Sep 09, 2015

Re: Matplotlib Plugin for Indigo 7 - New!

Decided to give this try - I'm a bit confused about what is needed in the CVS file

I think I made a mistake and now I'm getting this error in my log every 10 sec

Will this eventually give up and if not how to I clear it - reloading the plug-in did not stop it

After I sort it I'll bug you about what I can't figure out / understand - PS. thanks for this plugin - looks like it will be nice once I can get it working....

-----------

Traceback (most recent call last):
File "plugin.py", line 2247, in runConcurrentThread
File "plugin.py", line 615, in refreshTheCSV
ValueError: invalid literal for int() with base 10: 'None'

Matplotlib Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Schedule Temp Humidity via Adruino
Matplotlib Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
File "plugin.py", line 2247, in runConcurrentThread
File "plugin.py", line 615, in refreshTheCSV
ValueError: invalid literal for int() with base 10: 'None'

Matplotlib Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Matplotlib Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
File "plugin.py", line 2247, in runConcurrentThread
File "plugin.py", line 615, in refreshTheCSV
ValueError: invalid literal for int() with base 10: 'None'

Matplotlib Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Matplotlib Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
File "plugin.py", line 2247, in runConcurrentThread
File "plugin.py", line 615, in refreshTheCSV
ValueError: invalid literal for int() with base 10: 'None'

Matplotlib Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Matplotlib Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
File "plugin.py", line 2247, in runConcurrentThread
File "plugin.py", line 615, in refreshTheCSV
ValueError: invalid literal for int() with base 10: 'None'

Matplotlib Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Matplotlib Error Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
File "plugin.py", line 2247, in runConcurrentThread
File "plugin.py", line 615, in refreshTheCSV
ValueError: invalid literal for int() with base 10: 'None'

Matplotlib Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Matplotlib Error Error in plugin execution runConcurrentThread:

_______
Norm

Posted on
Sun Nov 13, 2016 6:44 pm
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Re: Matplotlib Plugin for Indigo 7 - New!

The CSV data has to be in the form of the example. The first column should be a timestamp and the second column should be "chartable" data. Like this:

Code: Select all
Timestamp,outdoor temperature
2016-11-10 22:52:11.511000,49.0
2016-11-10 23:07:16.981000,49.0
2016-11-10 23:22:23.031000,49.0
2016-11-10 23:27:10.241000,49.0
2016-11-10 23:27:55.256000,49.0
2016-11-10 23:29:25.278000,49.0
2016-11-10 23:29:55.271000,49.0
2016-11-10 23:45:01.073000,49.0
2016-11-11 00:00:07.628000,49.0
2016-11-11 00:15:13.816000,48.0
2016-11-11 00:30:19.329000,48.0
2016-11-11 00:45:24.691000,48.0
2016-11-11 01:00:30.039000,48.0
2016-11-11 01:15:35.413000,48.0
2016-11-11 01:30:40.732000,47.0
2016-11-11 01:45:46.004000,47.0
2016-11-11 02:00:51.428000,47.0
2016-11-11 02:15:57.425000,47.0
2016-11-11 02:31:03.213000,47.0
2016-11-11 02:46:08.644000,46.0
2016-11-11 03:01:14.114000,46.0
2016-11-11 03:16:19.914000,46.0

One observation per file.

If you're using the CSV Engine device, the 3 pieces of information you need for each CSV item are title, ID, and state. Like this:

For a device:
Source Title: wind speed
Source Device: 1899035475
Source State: windSpeed

Source Title: wind direction
Source Device: 1899035475
Source State: windDegrees

For a variable:
Source Title: foo
Source Device: 12345678
Source State: value

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Nov 13, 2016 8:28 pm
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Re: Matplotlib Plugin for Indigo 7 - New!

Just a quick followup. If you've added a faulty element with the CSV Engine, you'll need to delete that too.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Nov 13, 2016 10:07 pm
Brady offline
Posts: 57
Joined: May 25, 2016

Re: Matplotlib Plugin for Indigo 7 - New!

Thanks for the work on this! Started playing with it some this afternoon and after a small amount of trial and error, it seems to be working beautifully!

I'd love to see the ability to change font sizes per chart in the future and not have only a global setting. Some charts I am creating are for display on a Retina iPhone/iPad and some are for non retina screens. This leads to fonts only looking good on one of the two screens.

Posted on
Mon Nov 14, 2016 4:13 am
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Re: Matplotlib Plugin for Indigo 7 - New!

Brady wrote:
Thanks for the work on this! Started playing with it some this afternoon and after a small amount of trial and error, it seems to be working beautifully!

I'd love to see the ability to change font sizes per chart in the future and not have only a global setting. Some charts I am creating are for display on a Retina iPhone/iPad and some are for non retina screens. This leads to fonts only looking good on one of the two screens.

Glad to hear that the plugin is working well for you.

I must admit that I hadn't considered that retina/non-retina would make that much of a difference -- a complete oversight on my part. I'll add a font size override (or perhaps a retina/non-retina override) to the list of future enhancements.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Nov 14, 2016 9:51 am
norcoscia offline
User avatar
Posts: 508
Joined: Sep 09, 2015

Re: Matplotlib Plugin for Indigo 7 - New!

Still no joy - not sure what the issue is - maybe conflict with another plugin I'm running - I even had my wife take a look (and she is a programmer) - I tried puling info from a Netatmo device using

Temp test
1359889643
Temperature

and from my nest

NestTest
1875376265
ambient_temperature_f_int

both give me the same error - I'm doing this all from a remote client (mac) - not sure if that is an issue?

Also on the Mac that is running the Indigo server in the folder that should contain the CSV file - I see a cvs file titled "None.csv" it contains "Timestamp,None"

Any ideas?

_______
Norm

Posted on
Mon Nov 14, 2016 10:48 am
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Re: Matplotlib Plugin for Indigo 7 - New!

We'll get you going. There shouldn't be any conflicts but I'm not ready to rule that out completely.

First, since things aren't working for you now, please go into the CSV engine and delete any entries that you find in the drop-down list--there may also be entries that are "hidden" if you've added items with blank titles.

Second, please run the following python script and post the result into a reply to this thread using a code block:

Code: Select all
indigo.server.log(u"{0}".format(indigo.devices[1359889643].states))
indigo.server.log(u"{0}".format(indigo.devices[1875376265].states))

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Nov 14, 2016 11:01 am
norcoscia offline
User avatar
Posts: 508
Joined: Sep 09, 2015

Re: Matplotlib Plugin for Indigo 7 - New!

Here you go - thx for the help!

Code: Select all
   Interactive Shell               States : (dict)
     Humidity : 96 (integer)
     Temperature : 52.7 (real)
     When : 08:41:35 (string)
     batteryLevel : 74 (integer)
     batteryLevel.ui : 74% (string)
     battery_vp : 5210 (integer)
     date_max_temp : 00:02:07 (string)
     date_min_temp : 01:12:11 (string)
     max_temp : 53.1 (real)
     min_temp : 52.0 (string)
     rf_status : 63 (integer)
   Interactive Shell               States : (dict)
     ambient_temperature_c : 23 (real)
     ambient_temperature_c_int : 23 (integer)
     ambient_temperature_f : 73 (integer)
     ambient_temperature_f.ui : 73 F (string)
     ambient_temperature_f_int : 73 (integer)
     away_temperature_high_c : 32 (real)
     away_temperature_high_c_int : 32 (integer)
     away_temperature_high_f : 90 (integer)
     away_temperature_high_f_int : 90 (integer)
     away_temperature_low_c : 16.5 (real)
     away_temperature_low_c_int : 17 (integer)
     away_temperature_low_f : 62 (integer)
     away_temperature_low_f_int : 62 (integer)
     can_cool : true (bool)
     can_heat : true (bool)
     coolSetpoint_String :  (string)
     coolpointTrigger :  (string)
     days_since_last_connection : -1 (integer)
     fan_timer_active : false (bool)
     fan_timer_timeout : 1970-01-01T00:00:00.000Z (string)
     geoAssignId :  (string)
     geoAssignName :  (string)
     geoNESTRange : 0 (integer)
     geoNearRange : 0 (integer)
     has_fan : true (bool)
     has_leaf : false (bool)
     heatOrCool : Saving Energy (string)
     heatSetpoint_String : 73 (string)
     heatpointTrigger :  (string)
     hours_since_last_connection : 16 (integer)
     humidity : 55 (integer)
     humidityInput1 : 55 (real)
     humidityInput1.ui : 55  (string)
     humidityInputsAll : 55 (string)
     hvacFanMode : 0 (integer)
     hvacFanMode.ui : auto on (string)
     hvacFanModeIsAlwaysOn : false (bool)
     hvacFanModeIsAuto : true (bool)
     hvacOperationMode : 1 (integer)
     hvacOperationMode.ui : heat on (string)
     hvacOperationModeIsAuto : false (bool)
     hvacOperationModeIsCool : false (bool)
     hvacOperationModeIsHeat : true (bool)
     hvacOperationModeIsOff : false (bool)
     hvacOperationModeIsProgramAuto : false (bool)
     hvacOperationModeIsProgramCool : false (bool)
     hvacOperationModeIsProgramHeat : false (bool)
     hvac_mode : heat (string)
     hvac_mode.cool : false (bool)
     hvac_mode.heat : true (bool)
     hvac_mode.heat-cool : false (bool)
     hvac_mode.off : false (bool)
     hvac_state : off (string)
     is_online : true (bool)
     iscooling : No (string)
     isheating : No (string)
     last_connection : 2016-11-14T16:54:19.208Z (string)
     locale : en-GB (string)
     mins_since_last_connection : 0 (integer)
     name : Hallway (string)
     name_long : Hallway Thermostat (string)
     nest_client : 2 (integer)
     seconds_since_last_connection : 45 (integer)
     setpointCool : 0 (real)
     setpointCool.ui : 0.0 F (string)
     setpointHeat : 73 (real)
     setpointHeat.ui : 73.0 F (string)
     software_version : 5.6-7 (string)
     targetTrigger : true (string)
     target_temperature_c : 22.5 (real)
     target_temperature_c_int : 23 (integer)
     target_temperature_f : 73 (integer)
     target_temperature_f_int : 73 (integer)
     target_temperature_high_c : 24 (real)
     target_temperature_high_c_int : 24 (integer)
     target_temperature_high_f : 75 (integer)
     target_temperature_high_f_int : 75 (integer)
     target_temperature_low_c : 20 (real)
     target_temperature_low_c_int : 20 (integer)
     target_temperature_low_f : 68 (integer)
     target_temperature_low_f_int : 68 (integer)
     temperatureInput1 : 73 (real)
     temperatureInput1.ui : 73 F (string)
     temperatureInputsAll : 73 (string)
     temperature_scale : F (string)
     time_since_last_connection : -1 days 16 hours 0 mins 45 seconds (string)

_______
Norm

Posted on
Mon Nov 14, 2016 11:20 am
DaveL17 offline
User avatar
Posts: 4198
Joined: Aug 20, 2013

Re: Matplotlib Plugin for Indigo 7 - New!

Okay, that all looks good (unless you're flipping the state names with the device IDs which I doubt).

This is a long shot, but are you by any chance cutting and pasting the entries into the fields from somewhere else? Sometimes hidden characters or an extra space can come along with the paste. (A hidden character or extra space in the title probably won't hurt anything, but it won't work with an ID or state name).

Please check the path in the plugin configuration dialog to make sure that's entered correctly (both starts and ends with a forward slash).

Please also make sure that you click the "Add Item" button with each entry before you select Save. (If you don't add the item first, the changes won't commit.)

Lastly, please try this test: add a new CSV entry using a variable ID and in the Source State field enter the word 'value' (with no single quotes) and see if that works. You can always delete it later.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 1 guest