Node-red-contrib-home-assistant-websocket

  1. Use if state to optionally define criteria to send messages through the second output.

  1. I find I have to restart Nodered
1 Like
  1. They just show up for me. I donā€™t have to restart nodered.

I have additional question.
I am trying to send notification
So I use ā€œcall serviceā€ node.
If i do this from HA automation it looks like

- alias: 'test notify'
  trigger:
    platform: state
    entity_id: input_boolean.short_away
    to: 'off'
  action:
    - service: persistent_notification.create
      data:
        title: 'Test'
        message: Test test:)

But in ā€œcall serviceā€ node it is mandatory ā€œEntity Idā€ field. What I need to enter in this field?
Thanks.

Entity Id is not mandatory. Below youā€™ll find just the call service:

[
    {
        "id": "33ba201f.ee5f18",
        "type": "api-call-service",
        "z": "7a7f721a.5a661c",
        "name": "Test",
        "server": "2734ab02.42e8ec",
        "service_domain": "persistent_notification",
        "service": "create",
        "data": "{\"title\":\"Test\",\"message\":\"Test message\",\"notification_id\":\"11111\"}",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "x": 360,
        "y": 500,
        "wires": [
            []
        ]
    },
    {   
        "id": "caa29451.27147",
        "type": "inject",
        "z": "7a7f721a.5a661c",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 150,
        "y": 520,
        "wires": [
            [   
                "33ba201f.ee5f18"
            ]
        ]
    }   
]
1 Like

Thanks for example. I see now that my problem was in JSON syntax of data.

Iā€™m trying to pass a msg with entity id in msg.topic to Wait Until node, but it seems it doesnā€™t work with variables in Entity Id properties in this node.

Im typing: {{msg.topic}} and have tried other formats msg.data etcā€¦Am I doing it wrong?

The wait-until node currently doesnā€™t accept any inputs other than msg.reset and you canā€™t use templates in any of the input fields.

Ok, I understand. Is it possible to implement support for that? I want to create a flow where lights turns of after some minutes. And it would be alot cleaner if I could use same wait-until for all state-trigger nodes :slight_smile:

Yes, itā€™s possible but I need to rewrite the node to allow for topic dependent timers.

Currently, you can accomplish what youā€™re looking to do with a standard trigger node.

New Release v0.11.0

Possible Breaking Change for current-state node

The current-state node now allows the entity_id in the config to be overwritten by msg.payload.entity_id. This wasnā€™t possible before if there was a value in the entity_id field of the config. There are no nodes by default that output a msg.payload.entity_id other than older versions of the call-service node, users affected by this change should be limited. This change brings the current-state node more in line with the other nodes of this package by allowing config values to be set from msg.payload.

Bug Fixes

  • base-node: fix for using in/not in with context of msg/flow (49b9c26)
  • show msg for current state not and not others (d2c7929)
  • use relative path for haltif.js for hassio ingress (beb556a)
  • mustache-context: Fix for using both states/entity for templates (4b09811)

Features

  • current-state: able to override config entity id from payload (9217e09), closes #115

Full Changelog


Buy me a coffee For those that enjoy my work.

4 Likes

Hi,
Thanks for the work on this!

Iā€™m running both Home Assistant and NodeRed in Docker on Raspberry PI. Currently have v.0.20.5 of rpi-v8 image.

When it is starting - it is not loading the pallet with the following error:
nodered_1 | Welcome to Node-RED
nodered_1 | ===================
nodered_1 |
nodered_1 | 20 May 00:29:05 - [info] Node-RED version: v0.20.5
nodered_1 | 20 May 00:29:05 - [info] Node.js version: v8.1.3
nodered_1 | 20 May 00:29:05 - [info] Linux 4.14.79-v7+ arm LE
nodered_1 | 20 May 00:29:06 - [info] Loading palette nodes
nodered_1 | 20 May 00:29:10 - [warn] ------------------------------------------------------
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/server] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/server-events] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/server-state-changed] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/trigger-state] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/poll-state] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/api-call-service] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/ha-fire-event] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/api-current-state] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/ha-get-entities] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/api-get-history] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/api-render-template] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/ha-wait-until] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] [node-red-contrib-home-assistant-websocket/ha-api] SyntaxError: Unexpected token ā€¦
nodered_1 | 20 May 00:29:10 - [warn] ------------------------------------------------------
nodered_1 | 20 May 00:29:10 - [info] Settings file : /data/settings.js

Any ideas?

Thanks.

Try updating node.js. This package requires v8.12+ and looking at your logs youā€™re running v8.1.3

Looking for testers for the latest release candidate

Notable Changes:

  • Autocomplete across all nodes was reworked to work with multiple servers. Moved the autocomplete js to an external file so all nodes will now use the same code.
  • Added more custom output options from the trigger-state node and the ability to use templates within the custom output.
  • ā€œhalt if/if stateā€ has been changed to hopefully be more intuitive for new as well as existing users.

If State will now send the message to the first output if true and to the second if not. This is for the events-state, poll-state, and current-state nodes. The old behavior, sending the message to the second output if true, will continue to be in place until you edit one of the existing nodes via the UI and at that time the outputs will automatically be switched.

I would recommend backing up your flows, just in case, before trying this release.

How to install

npm (from within your node-red directory)

$ npm install node-red-contrib-home-assistant-websocket@next

npm from github

$ npm install https://github.com/zachowj/node-red-contrib-home-assistant-websocket#rc

hass.io users add this to your config

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

If you try this release please post a little feedback even if everything works for you. So I know if it is ready for release to all users.

Thanks.

1 Like

@Kermit Iā€™m giving it a shot right now as I have to rebuild my system. Iā€™ll post some thoughts shortly.

@Kermit ,

First, thanks so much for doing all this and sharing. My family has grown accustomed to all the automations Iā€™ve built in node red.

Iā€™d like to help test, but have a clarifying question. Iā€™m currently on the 0.11 release from the latest hassio add-on. When you edit one old-mode node, is just that individual node updated to the new behavior or are all the old nodes updated? I have dozens of current state nodes.

Thanks!

It is only the node you edit that will be updated to the new behaviour. All other nodes that you donā€™t edit will continue to function as they did in v0.11.0. There is no need to go through each node and update it, other than to test.

1 Like

@Kermit,
How would you like feedback on the rc release?

  1. so far so good in terms of functionality
  2. the output labels should be version-aware:
 outputLabels: function(index) {
  if (this.haltifstate) {
    if (index === 0) return "'If State' is true";
    if (index === 1) return "'If State' is false";
  }
},
  1. To make it easier to read a flow and know what is the true/false path without hovering over all current-state outputs, would you consider a) putting an indication that a node is in legacy mode in the label string or b) make the labelStyle italicā€¦ or anything you like.

Thanks!
Benjamin

1 Like

Thanks for the feedback.

How does this look as an indicator? Different color text if the deployed version is older than current version of node.

@Kermit, that looks great. Thanks!

New Release v0.12.0

Individuals nodes on the workspace will now have a version number associated with them. This will allow changes to be made to the structure of nodes without affecting all nodes of that type until you edit them. Legacy nodes will have a yellow font until the node has been upgraded to the current version.

ā€œIf Stateā€ Changes

If State will now send the message to the first output if true and to the second if not. This is for the events-state, poll-state, and current-state nodes. The old behavior, sending the message to the second output if true, will continue to be in place until you edit one of the existing nodes via the UI and at that time the outputs will automatically be switched. The output tooltips are version-aware and will display the correct text depending on the current version of the node. Hopefully, this change will make if state
more intuitive for new as well as existing users.

Bug Fixes

  • config-server: trying to get global namespace before it created (4472072)
  • css change for node label (22c645f)
  • css fixes for ā€˜if stateā€™ text boxes (78a2707)
  • fixed error reporting so catch node could be used (861c8e8), closes #119
  • more error reporting fixes (89346e2)
  • Update autocomplete on server change in ui (c8b2e09)

Features

  • if ā€˜if stateā€™ = true now outputs to the first output (9fdc6f5)
  • call-service: Ability to use alt tags for mustache templates (0624570), closes #117
  • current-state: Added ability to block input overrides to config (9d46441)
  • trigger-state: More options for custom outputs (3df9c18)

Full Changelog


Buy me a coffee For those that enjoy my work.

3 Likes