JeremyLaurenson / octoprint-emc2101

9 stars 2 forks source link

Debugging single sensor #9

Open axelnagel opened 1 year ago

axelnagel commented 1 year ago

First of all, thanks for sharing! I had trouble getting something to show up in the UI. So by luck I went down the rabbit hole and the called the plugin code manually which presented me the error:

Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_emc2101/EMC2101.py.bck", line 50, in <module> print('{0:0.1f} | {1:0.1f}'.format(temperature, fanspeed)) NameError: name 'temperature' is not defined

1.) logged in as pi

2.) activated python source oprint/bin/activate

3.) tested the script python /home/pi/oprint/lib/python3.7/site-packages/octoprint_emc2101/EMC2101.py 0 0

4.) copied the script and played around (not a python guy)

I changed the following code block:

itemperature = emc.internal_temperature
etemperature = emc.external_temperature
fanspeed = emc.fan_speed

if internal==0:
    temperature=itemperature
else:
    temperature=etemperature

to

    if internal==0:
    temperature = emc.internal_temperature
else:
    temperature = emc.external_temperature

fanspeed = emc.fan_speed

Now the script reports the temperature, bypassing the external or internal temperature call depending on the given flag, which failed in my case.