synman / OctoPrint-MqttChamberTemperature

1 stars 1 forks source link

Not working #1

Open sstarkey12 opened 8 months ago

sstarkey12 commented 8 months ago

Not working for me.

OctoPrint: 1.9.3 MQTT (0.8.14)

I appears that OctoPrint is connected to MQTT, but no chamber temp appears. Tried sending both JSON string and raw temp data. MQTT Explorer: image image

Plugin Config: image

Looking at the octoprint.log:

2024-01-13 13:01:04,798 - octoprint.plugin - ERROR - Error while calling plugin mqttchambertemperature
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_mqttchambertemperature/__init__.py", line 87, in on_after_startup
    self.mqtt_subscribe(self.mqttTempTopic, self.on_mqtt_subscription)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_mqtt/__init__.py", line 415, in mqtt_subscribe
    self._mqtt.subscribe(topic)
  File "/home/pi/oprint/lib/python3.7/site-packages/paho/mqtt/client.py", line 1488, in subscribe
    raise ValueError("No topic specified, or incorrect topic type.")
ValueError: No topic specified, or incorrect topic type.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/plugin/__init__.py", line 275, in call_plugin
    result = getattr(plugin, method)(*args, **kwargs)
  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_mqttchambertemperature/__init__.py", line 90, in on_after_startup
    self._logger.warn("unable to subscribe to [" + self.mqttTempTopic + "]")
TypeError: can only concatenate str (not "NoneType") to str
synman commented 8 months ago

This appears to be a problem with the topic name and how the Octoprint MQTT plug-in is handling it, or it is flat out a bad name.

We only care about 3d Printer Enclosure/temperature but it is unclear in your screenshot what the actual topic name/path is. In MQTT Explorer, select the temperature node then use its copy button to get the full path on your clipboard.

Share that here please.

Another thought is the MQTT python library may not like spaces in the topic name. Are you able to rename it to something with either dashes or underscores in whatever is controlling your mqtt bridge (I'm assuming zigbee)?

Do you run Home Assistant? I have an idea for working around it from there as well.

sstarkey12 commented 8 months ago

We only care about 3d Printer Enclosure/temperature but it is unclear in your screenshot what the actual topic name/path is. In MQTT Explorer, select the temperature node then use its copy button to get the full path on your clipboard.

Share that here please.

Fair assumption, but I did use the copy button, and that's the value I pasted on the plugin config page. For posterity, zigbee2mqtt/3d Printer Enclosure/temperature but I've changed it. The new topic is octoprint/enclosure which is a direct copy from MQTT Explorer.

image image

Another thought is the MQTT python library may not like spaces in the topic name. Are you able to rename it to something with either dashes or underscores in whatever is controlling your mqtt bridge (I'm assuming zigbee)?

After I posted the initial issue, the spaces thing occurred to me as well, so reconfigured my NodeRED node a little to remove them and publish to different topic. Didn't seem to help, but I'll keep this setup for now as it's a little cleaner.

image

Do you run Home Assistant? I have an idea for working around it from there as well.

I do use Home Assistant. With it I'm running the Node-RED add-on, Zigbee2MQTT add-on, and Mosquitto Broker add-on. I'm using NR to take the MQTT value from the sensor topic zigbee2mqtt/3d Printer Enclosure (which has a bunch of extra stuff in the JSON besides temperature) and feed just the temp by itself it to a custom MQTT topic, octoprint/enclosure. You don't specify the format of the MQTT message so I just assumed it would be a plain number value. I also have the Octoprint integration going inside HA, but don't really use it for control, just occasional monitoring.

I'm pretty sure Octoprint MQTT is working ok as I also use the MQTT Publish plugin to control the enclosure light and the printer (via smart switch), and it functioning. I did enable debug logging for the plugin but nothing has been captured yet. Did an uninstall and then reinstall the plugin (no errors on install) as well. I'm pretty stoked that you put this plugin together, so anything you need to troubleshoot I'm game.

synman commented 8 months ago

And you're getting the same error?

Running Octoprint on a pi?

sstarkey12 commented 8 months ago

Yes, on a pi 4. Let me delete the log file, restart Octoprint, and recheck it and I'll report back here.

synman commented 8 months ago

This has got to be something silly.

sstarkey12 commented 8 months ago

Ok....so it seems to be seeing the MQTT according to the logs:

2024-01-14 13:50:18,237 - octoprint.plugins.mqttchambertemperature - DEBUG - __init__: on_after_startup
2024-01-14 13:50:18,293 - octoprint.plugins.mqttchambertemperature - DEBUG - mqtt_publish registered
2024-01-14 13:50:18,299 - octoprint.plugins.mqttchambertemperature - DEBUG - subscribed to [octoprint/enclosure]
2024-01-14 13:50:18,311 - octoprint.plugins.mqttchambertemperature - DEBUG - mqtt_unsubscribe registered
2024-01-14 13:50:56,093 - octoprint.plugins.mqttchambertemperature - DEBUG - Received message for octoprint/enclosure: b'17.2'
2024-01-14 13:54:02,990 - octoprint.plugins.mqttchambertemperature - DEBUG - Received message for octoprint/enclosure: b'18.4'
2024-01-14 13:54:03,032 - octoprint.plugins.mqttchambertemperature - DEBUG - Received message for octoprint/enclosure: b'18.4'

But I'm not seeing anything on the Temperature panel in the Octoprint UI. I feel like I'm not doing something right here...lol.

synman commented 8 months ago

Nice... Go into your printer profile, enable the enclosure and you'll be good to go.

I'll tag this issue to update documentation.

sstarkey12 commented 8 months ago

Works! I'm guessing the spaces in the topic may have been the issue but I didn't know I had to enable it in my print profile....even though mine's not technically 'heated' you still have to add that to your print profile. Had no idea...Thanks for the assist and your patience. Great job on the plugin and I liked the links you added for making your enclosure heated for us new guys! Cheers!

synman commented 8 months ago

Great to see you got it all sorted out.

A couple things coming out of this (my own notes)