fix: store last_payload during MQTT topic discovery
The discovery message handler was missing the payload parameter, so topics were saved without their last value. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
73179f3040
commit
633d098206
@ -93,11 +93,18 @@ export function startDiscovery(brokerId: number, prefix?: string): Promise<MqttT
|
||||
resolve(getTopicsForBroker(brokerId));
|
||||
};
|
||||
|
||||
const onMessage = (topic: string): void => {
|
||||
const onMessage = (topic: string, payload: Buffer): void => {
|
||||
const payloadStr = payload.toString();
|
||||
if (!discoveredTopics.has(topic)) {
|
||||
discoveredTopics.add(topic);
|
||||
ensureTopicExists(brokerId, topic);
|
||||
}
|
||||
// Always update last_payload so the user sees the latest value
|
||||
const db = getDb();
|
||||
db.run(
|
||||
'UPDATE mqtt_topics SET last_payload = ? WHERE broker_id = ? AND topic = ?',
|
||||
[payloadStr, brokerId, topic]
|
||||
);
|
||||
};
|
||||
|
||||
if (existingClient && existingClient.connected) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user