hottis modbus relay 7
This commit is contained in:
@@ -150,11 +150,15 @@ class HomeAutomationClient {
|
||||
this.eventSource.close();
|
||||
}
|
||||
|
||||
this.eventSource = new EventSource(this.api('/realtime'));
|
||||
const realtimeUrl = this.api('/realtime');
|
||||
console.log('Connecting to SSE endpoint:', realtimeUrl);
|
||||
this.eventSource = new EventSource(realtimeUrl);
|
||||
|
||||
this.eventSource.onmessage = (event) => {
|
||||
console.log('Raw SSE event received:', event.data);
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
console.log('Parsed SSE data:', data);
|
||||
|
||||
// Normalize event format: convert API format to unified format
|
||||
const normalizedEvent = {
|
||||
@@ -163,6 +167,7 @@ class HomeAutomationClient {
|
||||
state: data.payload || data.state // Support both formats
|
||||
};
|
||||
|
||||
console.log('Normalized SSE event:', normalizedEvent);
|
||||
onEvent(normalizedEvent);
|
||||
|
||||
// Notify all registered listeners
|
||||
@@ -172,12 +177,17 @@ class HomeAutomationClient {
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to parse SSE event:', error);
|
||||
console.error('Failed to parse SSE event:', error, 'Raw data:', event.data);
|
||||
}
|
||||
};
|
||||
|
||||
this.eventSource.onopen = (event) => {
|
||||
console.log('SSE connection opened:', event);
|
||||
};
|
||||
|
||||
this.eventSource.onerror = (error) => {
|
||||
console.error('SSE connection error:', error);
|
||||
console.log('EventSource readyState:', this.eventSource.readyState);
|
||||
if (onError) {
|
||||
onError(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user