Skip to content

Commit

Permalink
feat(events-all): Added states_loaded and services_loaded
Browse files Browse the repository at this point in the history
Event:all node will now also receive states_loaded and services_loaded
in the event_type of home_assistant_client
  • Loading branch information
zachowj committed Mar 31, 2019
1 parent ccf9fbc commit b8097b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nodes/events-all/events-all.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ <h3>Client Events</h3>
<li>connected</li>
<li>disconnected</li>
<li>error</li>
<li>states_loaded</li>
<li>services_loaded</li>
</ul>
Structure
<dl class="message-properties">
Expand All @@ -90,7 +92,7 @@ <h3>Client Events</h3>
<dd>home_assistant_client:{event_type}</dd>

<dt>payload <span class="property-type">string</span></dt>
<dd>connecting | connected | disconnected | error</dd>
<dd>connecting | connected | disconnected | error | states_loaded | services_loaded</dd>

<dt>data <span class="property-type optional">string</span></dt>
<dd>Will contain the error message if event type is type error</dd>
Expand Down
16 changes: 16 additions & 0 deletions nodes/events-all/events-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ module.exports = function(RED) {
event: 'ha_events:' + (this.nodeConfig.event_type || 'all'),
handler: this.onHaEventsAll.bind(this)
});
this.addEventClientListener({
event: 'ha_events:states_loaded',
handler: this.onClientStatesLoaded.bind(this)
});
this.addEventClientListener({
event: 'ha_events:services_loaded',
handler: this.onClientServicesLoaded.bind(this)
});
}

onHaEventsAll(evt) {
Expand All @@ -34,6 +42,14 @@ module.exports = function(RED) {
});
}

onClientStatesLoaded() {
this.clientEvent('states_loaded');
}

onClientServicesLoaded() {
this.clientEvent('services_loaded');
}

onHaEventsClose() {
super.onHaEventsClose();
this.clientEvent('disconnected');
Expand Down

0 comments on commit b8097b8

Please sign in to comment.