Trigger IP display on printer

What is the problem?

The IP address of my printer changes periodically. If I run a print job, the ipOnConnect plugin will display the printer's IP on the LCD when the job ends. That's great!

The problem happens when no job is running, and Octoprint is not connected. I can't get to Octoprint to press the connect button, because I don't know the IP, and the plugin won't display the IP until Octoprint connects. (I think that's how it should work, based on this code: OctoPrint-ipOnConnect/octoprint_ipOnConnect at 025b99a633ac1aa94d08d71d950e0731e92ee5ab Β· jneilliii/OctoPrint-ipOnConnect Β· GitHubinit.py#L27)

Any suggestions on how to make the IP show up? Some method of making Octoprint connect, or some reason that it wouldn't be?

Thanks.

What did you already try to solve it?

Rebooting the printer doesn't help.

Have you tried running in safe mode?

No. I think Octoprint is running fine.

Did running in safe mode solve the problem?

Unknown.

Systeminfo Bundle (for a different printer that exhibits the same problems, I think)

browser.user_agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0
connectivity.connection_check: 1.1.1.1:53
connectivity.connection_ok: true
connectivity.enabled: true
connectivity.online: true
connectivity.resolution_check: octoprint.org
connectivity.resolution_ok: true
env.hardware.cores: 4
env.hardware.freq: 1200
env.hardware.ram: 918188032
env.os.bits: 32
env.os.id: linux
env.os.platform: linux2
env.plugins.pi_support.model: Raspberry Pi 3 Model B Rev 1.2
env.plugins.pi_support.octopi_version: 0.16.0
env.plugins.pi_support.throttle_state: 0x0
env.python.pip: 20.3.4
env.python.version: 2.7.13
env.python.virtualenv: true
octoprint.safe_mode: false
octoprint.version: 1.6.1
printer.firmware: Prusa-Firmware 3.10.0 based on Marlin
systeminfo.generator: systemapi

Additional information about your setup

Octoprint 1.6
Prusa MK3S+
Raspberry Pi 3B+

Hello @pingswept !

I assume with printer, you mean your OctoPrint setup, yes?

You could assign a static IP address for the Pi within the router you use.

Also you can connect via http://octopi.local

And BTW:

Sorry, yes, you are correct; when I said the IP of the printer, I meant the IP of the Pi attached to the printer.

A static IP is a good idea, but I don't have access to the router, as the machine is on a university network.

http://octopi.local is also a good idea, but it doesn't work. I'm not sure why, as I can see (2D) printers announcing themselves all over the place.

Is there a way I can verify that the Pi is broadcasting its hostname like that?

(Also, have I got the bundle right now?)

Thanks.

octoprint-systeminfo-20220401191036.zip (21.0 KB)

What to comes in mind to me is something like this:

The plugin in your case has to be altered to display the current IP address.

Maybe the plugin author can do this.

That's intriguing, but it looks like it's sending the IP out over the I2C bus, which would at least require a hardware change.

I guess I need to understand better how Octoprint connects to the printer via USB. I suspect what's happening is that Octoprint is connected to the printer, but the IP is only sent when a new connection is established, or a print finishes. When the Pi's IP changes, Octoprint is still connected via USB, so it doesn't report the new IP.

I wonder if Octoprint can trigger an event detectable by the ipOnConnect plugin when the IP changes.

Install the portlister plugin and configure your connection's port and baudrate and check the option to autoconnect. Then when you power off the printer and power it back on OctoPrint will automatically connect to the printer and then my plugin will send the IP to the LCD. That's probably the missing piece for your issue.

1 Like

Oooh, that sounds like exactly what's needed. Will give it a try. Thanks!

(And thanks for the onIPConnect plugin too!)

So I installed the PortLister plugin, but I'm not sure how to make Octoprint auto-connect.

I see the checkbox that says "Auto-connect on server startup," but checking that doesn't seem affect the behavior when I just cycle the printer power.

Am I missing another setting somewhere?

make sure the port and baud rate are set and not set to auto.

you may need to mess with the portlister settings for autoconnect delay as well.

Another thought would be to run a scheduled script on the RPi that checks the IP address and if it has changed, send an email, SMS, or a message with one of the other messaging applications.

@jneilliii Yeah, I set the port and baud rate. I'll try messing with the autoconnect delay.

@b-morgan That's an interesting idea.I could just write a little Python script that sends a UDP packet to a server every 15 minutes. I'm hesitant to write something odd that I'll have to remember the details of in a few months.

The RPi has a hostname associated with it (default is octopi) and in many larger networks, its name isn't octopi.local but octopi.<local dns domain>. Also you may not be the only OctoPrint user on your university network, so I'd change the hostname to something more unique to you. Then see if that hostname is resolvable.

@b-morgan I have 12 printers, and they all have unique hostnames, and I do control their DNS. Maybe I just need to install some dynamic DNS updater.

Looks like maybe something like this would work:

curl -D- -X PUT -H "Content-Type: application/json" \
        -H "X-Api-Key: $APIKEY" \
        -d "{\"rrset_name\": \"$SUBDOMAIN\",
             \"rrset_type\": \"A\",
             \"rrset_ttl\": 1200,
             \"rrset_values\": [\"$MY_IP\"]}" \
        $CURRENT_ZONE_HREF/$SUBDOMAIN/A

(from using gandi livedns as a Dynamic DNS server - Nicolas Herbaut, Associate Professor)

I assume all the printers use DHCP to obtain their IP address(es). Normally the DHCP server communicates with the DNS server so that when an IP address changes, DNS is automagically updated.

When a DHCP client asks for a new lease, it asks for the same IP address as it had previously. Are you turning the RPi systems off for extended periods? I turn my 3D printer off when I'm not using it but the RPi is left on. Even 12 of them won't consume that much power so I'd just leave them running.

Yes, everything you describe is correct, except that the university occasionally reconfigures its network, which gives all 12 printers new IPs. Most of the printers are running close to 24 hours per day, at least when school is underway, so they don't get turned off much.

I set up our domain name so that I wouldn't have to rely on the university to add new printers and such. Generally, it's worked fine, but this week, they're switching things around to debug some network problem, so I thought it would be worth trying to sort this out.

One other thing I just thought of that could interfere with this is if your printer is backpowered from the USB connection of the pi. This would prevent the printer from disconnecting altogether possibly. From memory you select the port and baudrate check the two boxes in the connection pane and click Connect. Once that is done the portlister plugin in theory should work.

Backpowering is certainly a possibility, though the printer does give the appearance of rebooting when the printer power is cut. Still, the USB port could possibly remain up?

Yeah, if the USB is able to power the printer's main board then a connection would already be established when the power was turned on I think. Which means portlister is probably already seeing the connection established and doesn't try to initiate the connection.

You mentioned you see other octopi.local announcing on the same network. Have you tried changing the host name of your device?