Skip to content

Commit

Permalink
fix: Fix for checking valid entity id
Browse files Browse the repository at this point in the history
Fix for checking valid entity id in the poll-state and current-state
nodes
  • Loading branch information
zachowj committed Mar 8, 2019
1 parent b46a4d5 commit 4ee501e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nodes/current-state/current-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = function(RED) {
{},
await this.nodeConfig.server.homeAssistant.getStates(entity_id)
);
if (!currentState)
if (!currentState.entity_id)
return logAndContinueEmpty(
`entity could not be found in cache for entity_id: ${entity_id}, sending empty payload`
);
Expand Down
9 changes: 6 additions & 3 deletions nodes/poll-state/poll-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ module.exports = function(RED) {
if (!this.isConnected) return;

try {
const pollState = await this.nodeConfig.server.homeAssistant.getStates(
this.entityId
const pollState = this.utils.merge(
{},
await this.nodeConfig.server.homeAssistant.getStates(
this.entityId
)
);

if (!pollState) {
if (!pollState.entity_id) {
this.warn(
`could not find state with entity_id "${this.entityId}"`
);
Expand Down

0 comments on commit 4ee501e

Please sign in to comment.