Skip to content

Commit 3eb7d93

Browse files
chvvkumarclaude
andcommitted
fix(mqtt): correct HA state topics and allow DEVICE_NAME env override
The HA discovery config for the Confidence and Detection Time sensors declared state_topics using an underscore (clouddetect_<id>_confidence) that did not match where publish_states() actually publishes (clouddetect_<id>/confidence). The sensors never received state. Aligned the config state_topics to use the slash form so they match. Also set AlpacaConfig.device_name default to an empty string so resolve_detect_overrides()'s pick() falls through to the DEVICE_NAME env var. The non-empty static default previously masked the env var. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 732e509 commit 3eb7d93

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

alpaca/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class AlpacaConfig:
6161
"""Configuration for the Alpaca server"""
6262
port: int = 11111
6363
device_number: int = 0
64-
device_name: str = "SimpleCloudDetect"
64+
device_name: str = ""
6565
device_description: str = "ASCOM SafetyMonitor based on ML cloud detection"
6666
driver_info: str = "ASCOM Alpaca SafetyMonitor v2.0 - Cloud Detection Driver"
6767
driver_version: str = "2.0"

detect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def publish_discovery_configs(self):
127127
confidence_config = {
128128
"name": "Confidence",
129129
"unique_id": f"clouddetect_{self.device_id}_confidence",
130-
"state_topic": f"{self.discovery_prefix}/sensor/clouddetect_{self.device_id}_confidence/state",
130+
"state_topic": f"{self.discovery_prefix}/sensor/clouddetect_{self.device_id}/confidence/state",
131131
"availability_topic": self.availability_topic,
132132
"unit_of_measurement": "%",
133133
"icon": "mdi:percent",
@@ -143,7 +143,7 @@ def publish_discovery_configs(self):
143143
time_config = {
144144
"name": "Detection Time",
145145
"unique_id": f"clouddetect_{self.device_id}_detection_time",
146-
"state_topic": f"{self.discovery_prefix}/sensor/clouddetect_{self.device_id}_detection_time/state",
146+
"state_topic": f"{self.discovery_prefix}/sensor/clouddetect_{self.device_id}/detection_time/state",
147147
"availability_topic": self.availability_topic,
148148
"unit_of_measurement": "s",
149149
"device_class": "duration",

0 commit comments

Comments
 (0)