Node-red-contrib-home-assistant-websocket


#101

I’m running hassio and websocket at version. 0.20 I tried ot update to version 0.3.1 but the install fails with this message:

image

Any suggestions? Tnx.


#102

When using the hass.io add-on for node-red you are unable to update node-red-contrib-home-assistant-websocket via the manage palette menu, There was an update for the hass.io add-on today that is using the latest released version of node-red-contrib-home-assistant-websocket.

For future instances where you may want to use the latest version but the add-on hasn’t been updated yet you can add this to your add-on config.

  "npm_packages": [
    "git+https://github.com/zachowj/node-red-contrib-home-assistant-websocket"
  ]

#103

Thanks, that worked great!


#104

Just curious, why are these “no connection” messages appearing recently?

image


#105

Before it would just show a generic API Error if the server responded that call-service was missing something or the connection to the server timed out. Now it shows No Connection if the connection status to the websocket was not equal to CONNECTED at the time of input on the node. The API Error still shows if the server responds with a error about the actually call-service call.

Basically means your last call didn’t go through because there was no connection to Home Assistant.


#106

Is this something I should address and fix or is it something that will eventually be worked out bewteen HA and websocket? Seems like there’s a race condition between websocket, node-red and HA since this call happens almost immediately?


#107

What’s triggering the flow? The start of Node-RED?

I am assuming the flow starts on the loading of Node-RED and it’s getting to the call-service node before Node-RED has finished connecting to HA. So yes, sort of a race condition from the looks of it.

If it fails the call-service it doesn’t retry it at the moment, I guess it could be a future feature.


#108

In the next release the current-state, event-state, trigger-state, and poll-state nodes will have better logic for the halt if field. You’ll be able to compare the current state against if it ==, !=, <, <=, >, >=, contains a substring or in an array.

With this new feature, I can also add the ability to have an addition output added to these nodes. So that when it succeeds the half if check instead of just dying and not sending any messages on it could send the message onto the second output. Basically how the trigger node works now for the top two outputs. I seem to run into this use case a lot where I have an event-state node then followed by a switch node to check the state. This could save you from this issue.

I 'm justing trying to poll here to see if this might be something people are interested in me adding. It probably won’t be in the upcoming release but the next one after that if users are interested.

  • Interested
  • Switch Nodes work fine
  • Whatever

0 voters


#109

It’s great to see that you’re willing to continue to improve the tools available for HASS and Node-Red integration. Just figured I’d say thank you for your efforts!


#110

Release v0.4.0

New Features

  • Ability to cast the state of event entities and payload to String/Number/Boolean

  • Changed halt if logic to be able to use different comparators to check the state for current-state, and events-state-change nodes

  • Poll-state now has halt if logic

Added

  • Added status times for success and error messages for the get template node (@jonathanadams)

  • Added timeSinceChangedMs to current-state, events-state, and trigger-state nodes entity.timeSinceChangedMs

Fixed

  • Autocomplete to use the correct entities/services if more than one server is setup (#49)

Since several users have asked about it I created a Buy me a coffee link. Don’t feel at all obligated to use it but all donations will be appreciated.

Buy me a coffee


#111

@Kermit

I am starting to use the state trigger node. I am having difficulties passing a constraint when it comes to property values, previous or current state work.

This is the ss of the node

Screenshot_2018-12-10_22-35-25

Now the debug output

In txt

  null,
  {
    "topic": "media_player.lounge_tv",
    "payload": "playing",
    "data": {
      "event_type": "state_changed",
      "entity_id": "media_player.lounge_tv",
      "event": {
        "entity_id": "media_player.lounge_tv",
        "old_state": {
          "entity_id": "media_player.lounge_tv",
          "state": "playing",
          "attributes": {
            "volume_level": 0.11,
            "is_volume_muted": true,
            "media_content_type": "channel",
            "source": "Netflix",
            "source_list": [
              "Live TV",
              "Netflix",
              "YouTube",
              "YouTube Kids",
              "kodi"
            ],
            "friendly_name": "Lounge TV",
            "entity_picture": "/api/media_player_proxy/media_player.lounge_tv?token=19a32c6f0f72b648a4&cache=23536eadafd901ab",
            "supported_features": 20409
          },
          "last_changed": "2018-12-10T12:29:45.054776+00:00",
          "last_updated": "2018-12-10T12:30:55.300413+00:00",
          "context": {
            "id": "c276db2347ad43fd90f058d05ae03586",
            "user_id": null
          }
        },
        "new_state": {
          "entity_id": "media_player.lounge_tv",
          "state": "playing",
          "attributes": {
            "volume_level": 0.11,
            "is_volume_muted": true,
            "media_content_type": "channel",
            "source": "Netflix",
            "source_list": [
              "Live TV",
              "Netflix",
              "YouTube",
              "YouTube Kids",
              "kodi"
            ],
            "friendly_name": "Lounge TV",
            "entity_picture": "/api/media_player_proxy/media_player.lounge_tv?token=19a32c6f0f3aebd89385832b648a4&cache=d13081ed50bd22c7",
            "supported_features": 20409
          },
          "last_changed": "2018-12-10T12:29:45.054776+00:00",
          "last_updated": "2018-12-10T12:31:06.291476+00:00",
          "context": {
            "id": "e4d1015a91124555a8003a98f0367134",
            "user_id": null
          },
          "timeSinceChangedMs": 81246
        }
      }
    },
    "failedComparators": [
      {
        "constraint": {
          "id": "fssrmq8xxwu",
          "targetType": "this_entity",
          "targetValue": "",
          "propertyType": "property",
          "propertyValue": "data.event.new_state.attributes.source",
          "comparatorType": "is",
          "comparatorValueDatatype": "str",
          "comparatorValue": "Netflix"
        },
        "constraintTarget": {
          "entityid": "media_player.lounge_tv",
          "state": {
            "entity_id": "media_player.lounge_tv",
            "old_state": {
              "entity_id": "media_player.lounge_tv",
              "state": "playing",
              "attributes": {
                "volume_level": 0.11,
                "is_volume_muted": true,
                "media_content_type": "channel",
                "source": "Netflix",
                "source_list": [
                  "Live TV",
                  "Netflix",
                  "YouTube",
                  "YouTube Kids",
                  "kodi"
                ],
                "friendly_name": "Lounge TV",
                "entity_picture": "/api/media_player_proxy/media_player.lounge_tv?token=19a32c6f0f3aeb2b648a4&cache=23536eadafd901ab",
                "supported_features": 20409
              },
              "last_changed": "2018-12-10T12:29:45.054776+00:00",
              "last_updated": "2018-12-10T12:30:55.300413+00:00",
              "context": {
                "id": "c276db2347ad43fd90f058d05ae03586",
                "user_id": null
              }
            },
            "new_state": {
              "entity_id": "media_player.lounge_tv",
              "state": "playing",
              "attributes": {
                "volume_level": 0.11,
                "is_volume_muted": true,
                "media_content_type": "channel",
                "source": "Netflix",
                "source_list": [
                  "Live TV",
                  "Netflix",
                  "YouTube",
                  "YouTube Kids",
                  "kodi"
                ],
                "friendly_name": "Lounge TV",
                "entity_picture": "/api/media_player_proxy/media_player.lounge_tv?token=19a32c6f0f3dfsfdas90efa872b648a4&cache=d13081ed50bd22c7",
                "supported_features": 20409
              },
              "last_changed": "2018-12-10T12:29:45.054776+00:00",
              "last_updated": "2018-12-10T12:31:06.291476+00:00",
              "context": {
                "id": "e4d1015a91124555a8003a98f0367134",
                "user_id": null
              },
              "timeSinceChangedMs": 81246
            }
          }
        },
        "comparatorResult": false
      }
    ]
  }
]

#112

For your constraint check against new_state.attributes.source is Netflix. The top level is already at data.event.


#113

I updated homeassistant to 0.84.1 and Node-red-contrib-home-assistant-websocket to 0.43 and now my device tracker only outputs ‘undefined’ when I check the presence with ‘current state’ or ‘events state’.

Did something change that I’m not aware off?


#114

Changed back to 0.83.3 and everything works again.


#115

Are you using the legacy API password? I haven’t really had a chance to look into it but did notice that HA is throwing errors when using the legacy API password with websockets in 0.84.1.


#116

I have something like this in my configuration.yaml

http:
  # Secrets are defined in the file secrets.yaml
    api_password: mypassword

Is that what you mean?


#117

Yes, that is what I was referring to. I would recommend changing over from using the legacy API password in the Node-RED to using the long-lived access token.

Here’s the issue about this same thing happening to app daemon user using the legacy API password.


#118

That token looks complicated. But I will look into it when I have some time. Not in a hurry to run the latest version of home assistant.


#119

When you find the time it’s actually really easy to set up. Checkout the simple instrutions in the link.


#120

That looks doable. I will try soon. Thanks.