Skip to content

Commit

Permalink
fix(fire-event): Handle errors when sending events via websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
zachowj committed Oct 2, 2024
1 parent cb72c3f commit 38167fc
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/nodes/fire-event/FireEventController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ export default class FireEventController extends InputOutputController<

this.status.setSending();

await this.homeAssistant.websocket.send({
type: 'fire_event',
event_type: eventType,
event_data: eventData,
});
try {
await this.homeAssistant.websocket.send({
type: 'fire_event',
event_type: eventType,
event_data: eventData,
});
} catch (e: unknown) {
if (e instanceof Error) {
this.status.setError(e.message);
done(e);
}
this.node.error(e);
return;
}

this.status.setSuccess(eventType);
send(message);
Expand Down

0 comments on commit 38167fc

Please sign in to comment.