Connecting your 3D printer to OctoPrint automatically

Recently I joined the group of 3d printer owners and OctoPrint users. After some days I got annoyed by the fact that so far nobody seems to have thought about automatically connecting a printer to OctoPrint after turning the printer on. If you start OctoPrint after your printer, everything works fine. But here OctoPrint runs 24⁄7 but I turn off the printer when it is done with printing. My solution of the problem is based on udev and systemd and should work on most recent Linux installations. »