IPv64 Domain Sensor#
IPv64DomainSensor is the Home Assistant sensor entity that exposes the IP address for each DNS record registered in an IPv64.net account. One sensor is created per entry in coordinator.data["subdomains"], with an icon of mdi:ip and a state equal to the record's current IP address .
Key files:
custom_components/ipv64/sensor.pyβ sensor class definition andasync_setup_entrycustom_components/ipv64/coordinator.pyβget_domain()buildscoordinator.data["subdomains"]
Constructor and Record Type#
IPv64DomainSensor.__init__ takes the full subdomain dict (not just the domain string). It reads the domain from subdomain[CONF_DOMAIN] and stores the record type as self._record_type = subdomain.get("type", "A").upper(), so a record without a type field is treated as an A record.
async_setup_entry passes the full subdomain record from coordinator.data["subdomains"] to IPv64DomainSensor.
How unique_id Is Assigned#
Each IPv64DomainSensor sets its unique_id in __init__ as:
ipv64_{domain}_{record_type}_ip
where record_type is lowercased. For example, a domain with both record types yields ipv64_example.ipv64.net_a_ip and ipv64_example.ipv64.net_aaaa_ip.
The identifier is derived from the domain name and the DNS record type (A vs AAAA).
Consequence for existing entities#
Before the record type was part of the ID, the unique_id was ipv64_{domain}_ip. Existing A-record sensors therefore get a new unique_id with the _a_ip suffix. This may create new entities and leave the old registry entries behind, which may need to be cleaned up manually.
Matching Records to Sensors#
Both native_value and extra_state_attributes look up the matching entry in coordinator.data["subdomains"] by both domain and record type (subdomain.get("type", "A").upper() compared with self._record_type). native_value returns that entry's IP address, or "unknown" if no entry matches.
A and AAAA records of the same domain are therefore shown independently, each with its own value and attributes.
Dual-Stack Domains#
get_domain() in the coordinator iterates every DNS record for every subdomain and appends each one to sub_domains_list . When a domain has both an A record and an AAAA record, this produces two list entries with the same domain value but different type values:
[
{"domain": "example.ipv64.de", "ip_address": "...", "type": "A", "ttl": "60"},
{"domain": "example.ipv64.de", "ip_address": "...", "type": "AAAA", "ttl": "60"}
]
async_setup_entry creates one IPv64DomainSensor per entry in that list. Because the record type is part of the unique_id, both sensors are registered rather than Home Assistant dropping the second one as a duplicate (see issue #456, reported against IPv64 integration v2.0.2).