Matplotlib Plugin for Indigo 7 - New!

Posted on
Mon Dec 05, 2016 9:50 am
Different Computers offline
User avatar
Posts: 2556
Joined: Jan 02, 2016
Location: East Coast

Re: Matplotlib Plugin for Indigo 7 - New!

Not sure if it fixed the error, but here's what I know:

I set the line color to stock RED.

Just opened the settings for the chart, and NO color was chosen. The popup was unpopulated.

The color error is gone, but I still see
Code: Select all
  Matplotlib Critical Error       Energy Line Chart: Check path to CSV file (x and y must have same first dimension)

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Dec 05, 2016 2:18 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Matplotlib Plugin for Indigo 7 - New!

Different Computers wrote:
Not sure if it fixed the error, but here's what I know:

I set the line color to stock RED.

Just opened the settings for the chart, and NO color was chosen. The popup was unpopulated.

The color error is gone, but I still see
Code: Select all
  Matplotlib Critical Error       Energy Line Chart: Check path to CSV file (x and y must have same first dimension)

Glad to hear that the color error has gone away. It sounds like there's something wrong with your CSV data. The plugin is able to chart files with different numbers of observations so that shouldn't be the problem. I just did another test to be sure and can chart using data from October for one line and from December for another line on the same chart.

You can do one of two things to address this. You can delete and re-enter the data elements within the CSV Engine (select save after deleting and then save after adding new elements) or you can go into the data folder (the path is in the plugin configuration dialog) and delete the offending CSV files in that folder. When the plugin cycles again, it will create a new file if it finds none exists. If you want to force a CSV file regeneration (after deleting them) you must reload the plugin or wait for the next refresh cycle. Selecting 'Redraw Charts Now' from the plugin menu will not regenerate the CSV files.

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

[My Plugins] - [My Forums]

Posted on
Mon Dec 05, 2016 5:24 pm
Different Computers offline
User avatar
Posts: 2556
Joined: Jan 02, 2016
Location: East Coast

Re: Matplotlib Plugin for Indigo 7 - New!

Looks like purging the data fixed it. Though now my issue is temp is being plotted on the same x axis as watts :D.

I'm sure I'll figure that out.

Strike that. Is that even possible? I don't see a way to do that inside the chart device. If the watt scale is 0-9000, my temp scale will all look like it's at 0, even if it's 100 degrees. I suppose I could switch to kilowatts.

Edit: I'm trying 2 transparent charts, one with time and one with energy. I'll overlay them.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Mon Dec 05, 2016 8:04 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Matplotlib Plugin for Indigo 7 - New!

Different Computers wrote:
Looks like purging the data fixed it. Though now my issue is temp is being plotted on the same x axis as watts :D.

I'm sure I'll figure that out.

Strike that. Is that even possible? I don't see a way to do that inside the chart device. If the watt scale is 0-9000, my temp scale will all look like it's at 0, even if it's 100 degrees. I suppose I could switch to kilowatts.

Edit: I'm trying 2 transparent charts, one with time and one with energy. I'll overlay them.

Excellent. Glad that we got that sorted.

Secondary Y axes are definitely on the to-do list -- let me know how overlaying transparent charts works out for you. You may find that the axes don't wind up the exact same size because there's a little bit of proportional sizing going on in the code.

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

[My Plugins] - [My Forums]

Posted on
Tue Dec 06, 2016 9:20 am
Different Computers offline
User avatar
Posts: 2556
Joined: Jan 02, 2016
Location: East Coast

Re: Matplotlib Plugin for Indigo 7 - New!

You may find that the axes don't wind up the exact same size because there's a little bit of proportional sizing going on in the code.
You called this in one.

Any suggestions on how to make this work better? I copied my Energy Plot device and plugged temp in instead, so all the size settings should be the same, but this is what I get. Close, but not great.
Attachments
Screen Shot 2016-12-06 at 10.18.30 AM.png
Screen Shot 2016-12-06 at 10.18.30 AM.png (247.32 KiB) Viewed 2896 times

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Dec 06, 2016 10:37 am
rvarela offline
Posts: 81
Joined: Oct 16, 2012

Re: Matplotlib Plugin for Indigo 7 - New!

Just to say that the solution you introduced in 0.2.04 to the 'state' confusion problem is a beautiful one. thanks.

Posted on
Tue Dec 06, 2016 4:43 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Matplotlib Plugin for Indigo 7 - New!

Different Computers wrote:
You called this in one.

Any suggestions on how to make this work better? I copied my Energy Plot device and plugged temp in instead, so all the size settings should be the same, but this is what I get. Close, but not great.

You might try playing with the custom size settings of the plots. I'm not sure it'll work, but it's worth a shot. If it doesn't work out, just set the custom sizes back to 'None' (without the single quotes).

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

[My Plugins] - [My Forums]

Posted on
Tue Dec 06, 2016 4:44 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Matplotlib Plugin for Indigo 7 - New!

rvarela wrote:
Just to say that the solution you introduced in 0.2.04 to the 'state' confusion problem is a beautiful one. thanks.

Hey, thanks. There's lots more to come!

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

[My Plugins] - [My Forums]

Posted on
Sat Dec 10, 2016 10:06 am
rvarela offline
Posts: 81
Joined: Oct 16, 2012

Re: Matplotlib Plugin for Indigo 7 - New!

Hi Dave,

I think I can use some advice. I would like to draw a plot comparing the accum. energy of several devices, just once a day (exact time does not matter). I think I can do it changing the refresh frequency in the plugin configuration to "once a day", but then I'll presumably loose the frequency of the other charts, which are now at 15 minutes intervals... (and that make sense for illumination, instant energy...etc.) Is there a way to solve this? Thanks,

Posted on
Sat Dec 10, 2016 4:53 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Matplotlib Plugin for Indigo 7 - New!

rvarela wrote:
Hi Dave,

I think I can use some advice. I would like to draw a plot comparing the accum. energy of several devices, just once a day (exact time does not matter). I think I can do it changing the refresh frequency in the plugin configuration to "once a day", but then I'll presumably loose the frequency of the other charts, which are now at 15 minutes intervals... (and that make sense for illumination, instant energy...etc.) Is there a way to solve this? Thanks,

You could reset the plugin frequency, but as you said, that would affect all of the charts simultaneously. I expect that I'll be able to introduce individual refresh rates at some point in the future.

Until that time, you can do the following. Create a schedule to update once per day -- at whatever time you want -- and have it run the following script. You'll need to plug in your own specific information at the top and I can help with that. Set the full_path to point to the same path where the plugin stores your other CSV files.

Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-

try:
    import os
    import datetime as dt

    full_path = '/full/path/to/data/directory/filename.csv'
    header_name = 'filename' # the same thing as the filename above (without the .CSV part)
    device_id = 12345678  # just the number, no quotes
    state_to_write = 'accumEnergyTotal'  # or whatever state you want to save
    target_lines = 30  # just a number, no quotes

    # If the appropriate CSV file doesn't exist, create it and write the header line.
    if not os.path.isfile(full_path):
        csv_file = open(full_path, 'w')
        csv_file.write('{0},{1}\n'.format('Timestamp', header_name))
        csv_file.close()

    # Determine the length of the CSV file and truncate if needed.
    backup = "{0} copy.csv".format(full_path)
    target_lines = int(target_lines) - 1

    # Make a backup of the CSV file in case something goes wrong.
    import shutil
    shutil.copyfile(full_path, backup)

    # Open the original file in read-only mode and count the number of lines.
    with open(full_path, 'r') as orig_file:
        lines = orig_file.readlines()
        orig_num_lines = sum(1 for _ in lines)

    # Write the file (retaining the header line and the last target_lines.
    if orig_num_lines > target_lines:
        with open(full_path, 'w') as new_file:
            new_file.writelines(lines[0:1])
            new_file.writelines(lines[(orig_num_lines - target_lines): orig_num_lines])

    # If all has gone well, delete the backup.
    os.remove(backup)

    # Write the latest value to the file.
    timestamp = u"{0}".format(indigo.server.getTime().strftime('%Y-%m-%d %H:%M:%S.%f'))
    csv_file = open(full_path, 'a')
    csv_file.write("{0},{1}\n".format(timestamp, indigo.devices[device_id].states[state_to_write]))
    csv_file.close()
except:
    indigo.server.log(u"Something has gone wrong saving the CSV data.", isError=True)

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

[My Plugins] - [My Forums]

Posted on
Sun Dec 11, 2016 7:24 am
rvarela offline
Posts: 81
Joined: Oct 16, 2012

Re: Matplotlib Plugin for Indigo 7 - New!

Wow!! Thanks! I'll try to implement it and come back.


Sent from my iPhone using Tapatalk

Posted on
Sat Dec 31, 2016 4:57 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: Matplotlib Plugin for Indigo 7 - New!

Dave, thanks for the plugin!

I wanted to give it a try now, but I have a problem with the "umlauts" characters.
I have them in my devices (German names) and the plugin seems to have an issue with them.

Code: Select all
31.12.2016 11:52:38
   Matplotlib Warning              Error generating column list. 'ascii' codec can't encode character u'\xfc' in position 12: ordinal not in range(128)


Maybe you can have a look into it when you have the time.

Indigo 7 and plugin 0.3.01

Thanks!

Wish you a Happy New Year!

Yassi

Posted on
Sat Dec 31, 2016 6:17 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Matplotlib Plugin for Indigo 7 - New!

Drat. There always seems to be at least one of these errors that sneaks through. Can you please look at the plugin debug log to show me the spot where the error first occurs? You can find the plugin debug log at /Library/Application Support/Perceptive Automation/Indigo 7/Logs/com.fogbert.indigoplugin.matplotlib/plugin.log

Gentle warning: there may have been more than one to sneak through. :D

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

[My Plugins] - [My Forums]

Posted on
Sat Dec 31, 2016 6:27 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: Matplotlib Plugin for Indigo 7 - New!

Dave,

here is some code.
If you need more, I will send you the whole log file.

Code: Select all
2016-12-31 11:52:38.814   DEBUG        Plugin.columnList                   *** CSV Device Column List Generated ***
2016-12-31 11:52:38.814   THREADDEBUG   Plugin.columnList                   valuesDict: {u'refreshStates': u'', u'editValue': u'', u'isColumnSelected': False, u'editState': u'', u'topSeparator': u'', u'csvEngineDeviceText': u'', u'previousKey': u'', u'addState': u'', u'addSource': u'', u'addItemFieldsCompleted': False, u'bottomSeparator': u'', u'deleteColumn': u'', u'addKey': u'', u'sep1': u'', u'addItemLabel': u'', u'columnDict': u"{u'k1': (u'Temperatur B\\xfcro Erdgeschoss', u'912011033', u'temperatureInput1'), 'k0': ('None', 'None', 'None')}", u'label1': u'', u'label5': u'', u'label6': u'', u'columnList': u'', u'numObsLabel': u'', u'sep2': u'', u'editSource': u'', u'label2.5': u'', u'numLinesToKeepText': u'', u'editKey': u'', u'numLinesToKeep': u'300', u'label0.5': u'', u'updateColumn': u'', u'addValue': u'', u'addColumn': u''}
2016-12-31 11:52:38.814   THREADDEBUG   Plugin.columnList                   filter =   typeId = csvEngine  targetId = 32493705
2016-12-31 11:52:38.819   THREADDEBUG   Plugin.pluginErrorHandler           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TRACEBACK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2016-12-31 11:52:38.819   THREADDEBUG   Plugin.pluginErrorHandler           !!! Traceback (most recent call last):
2016-12-31 11:52:38.819   THREADDEBUG   Plugin.pluginErrorHandler           !!!   File "plugin.py", line 482, in columnList
2016-12-31 11:52:38.819   THREADDEBUG   Plugin.pluginErrorHandler           !!!     prop_list   = [(key, "{0}".format(value[0])) for key, value in column_dict.items()]
2016-12-31 11:52:38.819   THREADDEBUG   Plugin.pluginErrorHandler           !!! UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 12: ordinal not in range(128)
2016-12-31 11:52:38.819   THREADDEBUG   Plugin.pluginErrorHandler           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2016-12-31 11:52:38.820   WARNING      Plugin.columnList                   Error generating column list. 'ascii' codec can't encode character u'\xfc' in position 12: ordinal not in range(128)
2016-12-31 11:52:49.796   DEBUG        Plugin.closedDeviceConfigUi         ** Closed Device Configuration Dialog **


Thx,
Yassi

Posted on
Sat Dec 31, 2016 6:34 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Matplotlib Plugin for Indigo 7 - New!

Perfect. Thanks very much. I will post a fix as quickly as possible.

Dave

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

[My Plugins] - [My Forums]

Page 8 of 19 1 ... 5, 6, 7, 8, 9, 10, 11 ... 19

Who is online

Users browsing this forum: No registered users and 6 guests