generate_ha: a command GA the actuator reports on is its own state address

Found on a real 1312-GA house (43 of 159 "switch without status" had a Read+Transmit
object on the command GA), measured on all seven corpus projects.

detect_missing_status already counted these as satisfied through pairing.self_reporting();
the generator did not and put them on the review list without a state_address. It now
uses the same function: no separate status found and the command GA has an R+T object
-> state_address = the command GA. Same for the on/off sibling of a dimmable light and
for brightness_state_address on a self-reporting brightness GA. Write-only objects still
go to review.

Corpus: no entity count changed, no address lost; review items 598 -> 555 on the house,
-36, -40, -12, -1, -32 on the others. Test C in test_real_house_fixes.py covers R+T,
write-only and a non-lighting switch.

Not verified on a live Home Assistant: state_address equal to address is accepted by the
KNX schema and xknx reads from it, but no running instance was used here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Nikolay Miroshnichenko
2026-09-16 18:34:40 +02:00
co-authored by Claude Opus 5
parent 3968ce2cde
commit 76249469bb
4 changed files with 53 additions and 7 deletions
+10 -1
View File
@@ -15,7 +15,7 @@ import yaml
from .project import LoadedProject, GARecord
from .analyze import _is_status_ga
from .pairing import find_status, base_tokens, function_status_pairs
from .pairing import find_status, base_tokens, function_status_pairs, self_reporting
# Venetian-blind slat (tilt) detection: a slat GA is the tilt of its parent
# blind, not a standalone cover.
@@ -440,12 +440,16 @@ def generate_ha_yaml(project: LoadedProject) -> dict[str, Any]:
if st5:
entity["brightness_state_address"] = st5.address
consumed.add(st5.address)
elif self_reporting(ga, project):
entity["brightness_state_address"] = ga.address
if sib is not None:
entity["address"] = sib.address
s1 = status_for_dpt(sib, 1) # on/off status (1.x)
if s1:
entity["state_address"] = s1.address
consumed.add(s1.address)
elif self_reporting(sib, project):
entity["state_address"] = sib.address
consumed.add(sib.address)
attach_colour(entity, ga) # RGB/RGBW/xyY/colour-temp of this zone
lights.append(entity)
@@ -498,6 +502,11 @@ def generate_ha_yaml(project: LoadedProject) -> dict[str, Any]:
if st:
entity["state_address"] = st.address
consumed.add(st.address)
elif self_reporting(ga, project):
# The actuator's status object (Read + Transmit) is linked to the command GA
# itself, so the command GA is its own state. detect_missing_status already
# treats these as satisfied; the generator now agrees.
entity["state_address"] = ga.address
else:
review.append({"reason": "light_without_status" if is_light else "switch_without_status",
"address": ga.address, "name": ga.name})