jneilliii / OctoPrint-PlotlyTempGraph

25 stars 7 forks source link

Not able to show values from mini plugins #50

Closed thomas82kj closed 1 year ago

thomas82kj commented 1 year ago

I have been trying for some time now to use this plugin to graph some more values. But i have simply not been able to get anything more than the tool and bed temperature on the graph, which have been there the whole time.

I started by modifying the heater example plugin to fit repetier firmware (the order of @: and B@: is reversed). I believe my modified version should work now, i have been able to see that the values gets picked up in the log files: 2023-09-27 18:40:50,877 - octoprint.plugins.heater_temps_rep - DEBUG - {'nozzle_heater': (36.0, None), 'bed_heater': (255.0, None)}

Despite this I get nothing on the graph. Today i also tried the test plugin which generate random values: https://github.com/jneilliii/OctoPrint-PlotlyTempGraph/blob/b5f5a4f4fad5c3da892d457ea25ae40654d5f1e8/test%20plotly%20graph.py

To my surprise this does not add any values to the trend either. Any clue where to look next? I am using plugin version 0.1.5 on Octopi 0.18.0 (Octoprint 1.9.2)

jneilliii commented 1 year ago

Should work that way. Might be easier for me to see your code and get you to share an example temp report line from the terminal tab to debug further. It's odd the random example doesn't work either. You don't have any errors in octoprint.log?

thomas82kj commented 1 year ago

Here's an example temp report line: Recv: T:227.45 /230 B:77.98 /78 B@:255 @:164

After searching the log for error, i stumbled upon something:

2023-09-27 18:29:09,712 - octoprint.plugin.core - INFO - Initialized 23 plugin implementation(s)
2023-09-27 18:29:09,737 - octoprint - ERROR - Error while trying to migrate settings for plugin plotlytempgraph, ignoring it
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/__init__.py", line 532, in init_settings_plugin_config_migration_and_cleanup
    implementation._identifier, implementation
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/__init__.py", line 516, in settings_plugin_config_migration_and_cleanup
    settings_migrator(settings_version, stored_version)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1686, in wrapper
    return f(*args, **kwargs)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_plotlytempgraph/__init__.py", line 31, in on_settings_migrate
    if current <= 2:
TypeError: '<=' not supported between instances of 'NoneType' and 'int'

Here follows my code, but should not differ much from the standard example:

from __future__ import absolute_import

import octoprint.plugin
import re

class HeaterTemp(octoprint.plugin.StartupPlugin, octoprint.plugin.RestartNeedingPlugin):
    def __init__(self):
        self.last_heater_temps = dict()
        self.heater_temp_regex = re.compile(r".+B@:(?P<bed_heater>\d+)\s@:(?P<nozzle_heater>\d+)")

    def gcode_callback(self, comm, line, *args, **kwargs):
        if "@:" not in line:
            return line

        heater_temp_matches = self.heater_temp_regex.match(line)
        nozzle_heater = heater_temp_matches.group("nozzle_heater")
        bed_heater = heater_temp_matches.group("bed_heater")
        self.last_heater_temps["nozzle_heater"] = (float(nozzle_heater), None)
        self.last_heater_temps["bed_heater"] = (float(bed_heater), None)
        self._logger.debug(self.last_heater_temps)
        return line

    def temp_callback(self, comm, parsed_temps):
        parsed_temps.update(self.last_heater_temps)
        return parsed_temps

__plugin_name__ = "Heater Temps"
__plugin_pythoncompat__ = ">=2.7,<4"
__plugin_version__ = "0.1.0"
__plugin_implementation__ = HeaterTemp()
__plugin_hooks__ = {
    "octoprint.comm.protocol.gcode.received": __plugin_implementation__.gcode_callback,
    "octoprint.comm.protocol.temperatures.received": __plugin_implementation__.temp_callback
}
jneilliii commented 1 year ago

After searching the log for error, i stumbled upon something

Thanks, this is definitely something that could be fixed and might have been part of the issue during an upgrade process and could be the cause of the settings weirdness mentioned in #49. I suspect this happens when you also clear the settings from plugin manager as mentioned you did in that other issue.

This however should not have caused the plugin to not load and pick up the data from the single file plugins. I'll dive into this one over the weekend and see if there's anything that stands out. It would also be helpful to know if there are any errors in your browser's developer tools (press F12 on keyboard and look at console tab, preferably Chrome) during initial page load?

thomas82kj commented 1 year ago

There is actually quite a few errors in the console (I have copied the beginning of some of them, from firefox)

Error plotting history data for bed_heater [packed_plugins.js:9652:25](http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25)
    fromHistoryData http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9652
    callViewModelIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1798
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792
    Pn http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:30
    ur http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:51
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792
    callViewModels http://192.168.87.118/static/webassets/packed_core.js?06860971:1791
    _onHistoryData http://192.168.87.118/static/webassets/packed_core.js?06860971:1672
    _ifInitialized http://192.168.87.118/static/webassets/packed_core.js?06860971:1686
    _onHistoryData http://192.168.87.118/static/webassets/packed_core.js?06860971:1672
    propagateMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:24
    Pn http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:30
    ur http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:51
    propagateMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:24
    onMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:31

Error plotting history data for nozzle_heater [packed_plugins.js:9652:25](http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25)
    fromHistoryData http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9652
    callViewModelIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1798
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792
    Pn http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:30
    ur http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:51
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792
    callViewModels http://192.168.87.118/static/webassets/packed_core.js?06860971:1791
    _onHistoryData http://192.168.87.118/static/webassets/packed_core.js?06860971:1672
    _ifInitialized http://192.168.87.118/static/webassets/packed_core.js?06860971:1686
    _onHistoryData http://192.168.87.118/static/webassets/packed_core.js?06860971:1672
    propagateMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:24
    Pn http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:30
    ur http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:51
    propagateMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:24
    onMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:31

TypeError: a is undefined
    Ua http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:129
    p http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:134
    ec http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:134
    G http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    x http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:133
    Qd http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:134
    yd http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    zd http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    ha http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    Hc http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    notifySubscribers http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    xa http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    b http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    lookup_visibility http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9350
    fromHistoryData http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9611
    callViewModelIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1798
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792
    Pn http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:30
    ur http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:51
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792

Error: You cannot apply bindings multiple times to the same element.
    p http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:131
    k http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:131
    vc http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:132
    c http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:133
    b http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:133
    c http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:133
    r http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:134
    ec http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:134
    G http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    x http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:133
    Qd http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:134
    yd http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    zd http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    ha http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    Hc http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    notifySubscribers http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    xa http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    b http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:130
    lookup_visibility http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9350
    fromHistoryData http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9611
    callViewModelIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1798
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792

TypeError: name_map.hover_template is not a function
    lookup_hover_template http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9373
    fromHistoryData http://192.168.87.118/static/webassets/packed_plugins.js?e87aab25:9618
    callViewModelIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1798
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792
    Pn http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:30
    ur http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:51
    callViewModelsIf http://192.168.87.118/static/webassets/packed_core.js?06860971:1792
    callViewModels http://192.168.87.118/static/webassets/packed_core.js?06860971:1791
    _onHistoryData http://192.168.87.118/static/webassets/packed_core.js?06860971:1672
    _ifInitialized http://192.168.87.118/static/webassets/packed_core.js?06860971:1686
    _onHistoryData http://192.168.87.118/static/webassets/packed_core.js?06860971:1672
    propagateMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:24
    Pn http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:30
    ur http://192.168.87.118/static/webassets/packed_libs.js?6bee1dee:51
    propagateMessage http://192.168.87.118/static/webassets/packed_client.js?3339ed72:24
jneilliii commented 1 year ago

Yep, missed the hover_template in part of the code where the entry gets automatically added to the settings. Since it was missing caused the data to not load right or save the new entry into settings. Pushing update now and will release version 0.1.7 with fix.

thomas82kj commented 1 year ago

I have just updated, and it seems to work like it should now. Thanks a lot for the very quick reaction. Now my next issue will be to somehow filter the values, especially since my bed heater does on/off control, so it's really something like the average value over a minute or so that's interesting. I guess I will need to create some static variables in the mini plugin, and probably convert some strings to numbers to do an averaging or low pass algorithm.