New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Reply To: Seeing the changed IP address of the headless Pi through Hermetry

Translated from Türkçe by AI ·

If it is already connected to Hermetry, send the IP there as a client attribute. I always do it this way on the test devices at the pharmaceutical plant.Right after connecting, and again if the IP changes, publish to v1/attributes:

import socket, json
def lan_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("10.255.255.255", 1))
ip = s.getsockname()[0]; s.close(); return ip
def on_connect(c, u, f, rc):
c.publish("v1/attributes", json.dumps({"lan.ip": lan_ip(), "host": socket.gethostname()}), qos=1)

On the device page, in the Attributes tab, when you select the Client scope, lan.ip appears there with its last update time. The example in the documentation also uses the lan.ip key anyway.Don’t rely on the IP address field in Overview: it holds the address the latest connection came from, so if there is NAT on the way out it will be the school’s external IP, which is useless for SSH.Öznitelikler

Accepted solution♥ 5